final receipt update

This commit is contained in:
EugeneTes
2026-01-22 11:09:38 +01:00
parent 9fbc61dede
commit fcb192b797
31 changed files with 2679 additions and 655 deletions

View File

@@ -16,6 +16,39 @@
<None Update="kitchen-u220.template">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Samples\bar-default.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Samples\fallback.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Samples\final-receipt.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Samples\kitchen-default.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Samples\kitchen-u220.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Templates\assignments.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Templates\bar-default.template">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Templates\fallback.template">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Templates\final-receipt.template">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Templates\kitchen-default.template">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Templates\kitchen-u220.template">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@@ -6,62 +6,22 @@ using Inspectron.Epson.Templates.Interpreter;
using Inspectron.Epson.Templates.Language;
using System.Text.Json;
var receipt = new KitchenReceipt
{
Title = "Warme Küche",
TransactionDateTime = new DateTime(2025, 10, 23, 12, 18, 0),
ReceiptNumber = "132018166",
WaiterName = "Mariano Amato",
WaiterId = "32 (VK Restaurant)",
TableNumber = "22",
SpecialInstruction = "Next dish"
};
// Add dishes (this section can be empty if no dishes were ordered)
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" }
}
});
// Add additional info
var serializedReceipt = JsonSerializer.Serialize(receipt, new JsonSerializerOptions { WriteIndented = true });
var lexer = new Lexer(File.ReadAllText("kitchen-u220.template"));
var parser = new Parser(lexer.Tokenize().Tokens);
var template = parser.Parse().Template;
PrinterProfile _profileT30 = new("tm-t30iii", "TM-T30III", 48, 24, false);
PrinterProfile _profile220 = new("tm-220", "TM-220", 33, 18, true);
var interpreter = new TemplateInterpreter(_profile220);
var printCommands = interpreter.Interpret(template, serializedReceipt);
var printCommands = CreateCommands(_profileT30, "Templates\\final-receipt.template", "Samples\\final-receipt.json");
Console.WriteLine("=== PRINT COMMANDS ===\n");
var printer = new HtmlPrinter(@".\test.html", paperWidth: 258);
var printer = new HtmlPrinter(@".\test.html", paperWidth: 384);
await printer.ConnectAsync("");
bool useDelay = false;
//var printer = new EpsonPrinter();
@@ -97,4 +57,17 @@ foreach (var command in printCommands)
await printer.FeedLinesAsync(5);
if (useDelay) await Task.Delay(200 * 5);
await printer.CutAsync();
await printer.CutAsync();
List<PrintCommand> CreateCommands(PrinterProfile printerProfile, string templateFile,string jsonFile)
{
var lexer = new Lexer(File.ReadAllText(templateFile));
var parser = new Parser(lexer.Tokenize().Tokens);
var template = parser.Parse().Template;
var interpreter = new TemplateInterpreter(printerProfile);
var printCommands = interpreter.Interpret(template, File.ReadAllText(jsonFile));
return printCommands;
}

View File

@@ -0,0 +1,64 @@
{
"Title": "Bar",
"TransactionDateTime": "2025-10-23T20:30:00",
"ReceiptNumber": "132018300",
"WaiterName": "Thomas Weber",
"WaiterId": "28 (Bar Staff)",
"TableNumber": "B5",
"SpecialInstruction": "VIP Table",
"Gangs": [
{
"Id": 1,
"Name": "Round",
"Dishes": [
{
"Number": 2,
"Name": "Aperol Spritz",
"Modifications": {
"Removed": [],
"Added": ["Extra Ice"]
},
"Comment": null
},
{
"Number": 1,
"Name": "Negroni",
"Modifications": {
"Removed": ["Orange Peel"],
"Added": []
},
"Comment": "Stirred, not shaken"
},
{
"Number": 3,
"Name": "San Pellegrino 50cl",
"Modifications": {
"Removed": [],
"Added": []
},
"Comment": null
}
]
}
],
"Dishes": [
{
"Number": 2,
"Name": "Espresso",
"Modifications": {
"Removed": [],
"Added": []
},
"Comment": null
},
{
"Number": 1,
"Name": "Cappuccino",
"Modifications": {
"Removed": [],
"Added": ["Oat Milk"]
},
"Comment": "Extra hot"
}
]
}

View File

@@ -0,0 +1,4 @@
{
"Title": "General Receipt",
"TransactionDateTime": "2025-12-01T14:00:00"
}

View File

@@ -0,0 +1,108 @@
{
"CompanyName": "Klingler Gastro AG",
"Address1": "Munzplatz 3",
"Address2": "CH-8001 Zurich",
"Phone": "043 321 22 22",
"ReceiptNumber": "1-81-202",
"DateTime": "2025-12-16T14:58:00",
"Guests": 2,
"Total": 160.00,
"Currency": "CHF",
"TotalInAlternateCurrency": 172.80,
"AlternateCurrency": "EUR",
"PaymentMethod": "MASTER",
"PaymentAmount": 160.00,
"WaiterName": "Yves",
"Terminal": "Hauptkasse ZH",
"TableNumber": "12",
"VatNumber": "CHE-449.635.880 MWST",
"ThankYouMessage": "Das Team bedankt sich herzlich fur Ihren",
"GoodbyeMessageLine1": "Besuch.",
"GoodbyeMessageLine2": "Auf Wiedersehen.",
"Items": [
{
"Quantity": 1,
"Description": "San Pellegrino 50cl",
"UnitPrice": 6.50,
"TotalPrice": 6.50,
"TaxCategory": "A"
},
{
"Quantity": 1,
"Description": "Panna 50cl",
"UnitPrice": 6.50,
"TotalPrice": 6.50,
"TaxCategory": "A"
},
{
"Quantity": 1,
"Description": "Granini Tomatensaft",
"UnitPrice": 5.50,
"TotalPrice": 5.50,
"TaxCategory": "A"
},
{
"Quantity": 2,
"Description": "Business Lunch Menu Seco",
"UnitPrice": 44.00,
"TotalPrice": 88.00,
"TaxCategory": "A"
},
{
"Quantity": 2,
"Description": "Brunello di Montalcino 1",
"UnitPrice": 16.00,
"TotalPrice": 32.00,
"TaxCategory": "A"
},
{
"Quantity": 2,
"Description": "Espresso",
"UnitPrice": 5.50,
"TotalPrice": 11.00,
"TaxCategory": "A"
},
{
"Quantity": 1,
"Description": "Tip",
"UnitPrice": 10.50,
"TotalPrice": 10.50,
"TaxCategory": "B"
}
],
"TaxBreakdown": [
{
"Category": "A",
"Rate": 8.1,
"Gross": 149.50,
"Net": 138.30,
"TaxAmount": 11.20,
"Currency": "CHF"
},
{
"Category": "B",
"Rate": 0,
"Gross": 10.50,
"Net": 10.50,
"TaxAmount": 0.00,
"Currency": "CHF"
}
],
"TerminalReceipt": {
"ReceiptType": "*** Kundenbeleg ***",
"BookingType": "Buchung",
"PaymentSystem": "TWINT",
"TransactionNumber": "XXXXXXXXXXXXXXX1494",
"TransactionDateTime": "2025-11-11T12:34:49",
"TerminalId": "31108834",
"AID": "A0000015749E",
"TransactionSeqCount": "6127",
"TransactionRefNo": "99036644599",
"AuthCode": "0d3396",
"AcquirerId": "2",
"EftAmount": 67.00,
"TipAmount": 6.70,
"TotalEftAmount": 73.70,
"Currency": "CHF"
}
}

View File

@@ -0,0 +1,60 @@
{
"Title": "Warme Kuche",
"TransactionDateTime": "2025-10-23T12:18:00",
"ReceiptNumber": "132018166",
"WaiterName": "Mariano Amato",
"WaiterId": "32 (VK Restaurant)",
"TableNumber": "22",
"SpecialInstruction": "Next dish",
"Gangs": [
{
"Id": 1,
"Name": "Gang",
"Dishes": [
{
"Number": 1,
"Name": "Avocado Sashimi",
"Modifications": {
"Removed": ["Wasabi"],
"Added": ["Extra Ginger"]
},
"Comment": "No soy sauce"
},
{
"Number": 1,
"Name": "Baby Spinach Salad with Truffl",
"Modifications": {
"Removed": [],
"Added": []
},
"Comment": null
}
]
},
{
"Id": 2,
"Name": "Gang",
"Dishes": [
{
"Number": 1,
"Name": "Beef Tataki",
"Modifications": {
"Removed": ["Onion"],
"Added": ["Extra Sauce"]
},
"Comment": "Medium rare"
},
{
"Number": 1,
"Name": "Salmon Taco",
"Modifications": {
"Removed": [],
"Added": ["Extra Lime"]
},
"Comment": null
}
]
}
],
"Dishes": []
}

View File

@@ -0,0 +1,39 @@
{
"Title": "Kalte Kuche",
"TransactionDateTime": "2025-11-15T18:45:00",
"ReceiptNumber": "132018200",
"WaiterName": "Sofia Mueller",
"WaiterId": "45 (VK Restaurant)",
"TableNumber": "8",
"SpecialInstruction": null,
"Gangs": [],
"Dishes": [
{
"Number": 2,
"Name": "Caesar Salad",
"Modifications": {
"Removed": ["Croutons"],
"Added": ["Extra Parmesan"]
},
"Comment": "Dressing on the side"
},
{
"Number": 1,
"Name": "Carpaccio",
"Modifications": {
"Removed": [],
"Added": []
},
"Comment": null
},
{
"Number": 3,
"Name": "Bruschetta",
"Modifications": {
"Removed": [],
"Added": ["Extra Basil"]
},
"Comment": null
}
]
}

View File

@@ -0,0 +1,25 @@
{
"assignments": [
{
"receiptType": 1,
"profileId": "tm-t30iii",
"template": "kitchen-default.template"
},
{
"receiptType": 1,
"profileId": "tm-u220ii",
"template": "kitchen-u220.template"
},
{
"receiptType": 1,
"profileId": null,
"template": "kitchen-default.template"
},
{
"receiptType": 2,
"profileId": null,
"template": "bar-default.template"
}
],
"fallbackTemplate": "fallback.template"
}

View File

@@ -0,0 +1,59 @@
#red,big,center# {Title} #
---
#center# {TransactionDateTime:dd-MMM-yy HH:mm} Nr.:{ReceiptNumber} #
#center# {WaiterName} #
#center# {WaiterId} #
#big,bold,center# Tisch: {TableNumber} #
@if SpecialInstruction
#big,bold,center# {SpecialInstruction} #
@end
---
@foreach gang in Gangs
#red,center# {gang.Id}. {gang.Name} #
@foreach drink in gang.Dishes
{drink.Number}x {drink.Name}
@if drink.Modifications.Removed.count > 0
@foreach removed in drink.Modifications.Removed
#bold# - {removed} #
@end
@end
@if drink.Modifications.Added.count > 0
@foreach added in drink.Modifications.Added
#bold# + {added} #
@end
@end
@if drink.Comment
#bold# Comment: {drink.Comment} #
@end
@end
@end
@if Gangs.count > 0
---
@end
@foreach drink in Dishes
{drink.Number}x {drink.Name}
@if drink.Modifications.Removed.count > 0
@foreach removed in drink.Modifications.Removed
#bold# - {removed} #
@end
@end
@if drink.Modifications.Added.count > 0
@foreach added in drink.Modifications.Added
#bold# + {added} #
@end
@end
@if drink.Comment
#bold# Comment: {drink.Comment} #
@end
@end
@if Dishes.count > 0
---
@end

View File

@@ -0,0 +1,9 @@
#center# Receipt #
---
@if Title
{Title}
@end
@if TransactionDateTime
{TransactionDateTime:dd-MMM-yy HH:mm}
@end
---

View File

@@ -0,0 +1,60 @@
#center# {CompanyName} #
#center# {Address1} #
#center# {Address2} #
#center# {Phone} #
@row bold
|24|Rechnung Nr. {ReceiptNumber}|24,right|{DateTime:HH:mm dd.MM.yyyy}
Guests: {Guests}
@foreach item in Items
{item.Quantity}x {item.Description} {right:{item.UnitPrice:F2} {item.TotalPrice:F2} {item.TaxCategory}}
@end
{right:---------}
#big,bold,center# Summe: {Total:F2} {Currency} #
@if TotalInAlternateCurrency
{right:{TotalInAlternateCurrency:F2} {AlternateCurrency}}
@end
#bold# {PaymentMethod} {right:{PaymentAmount:F2} {Currency}} #
@if TaxBreakdown.count > 0
MwSt % Brutto Netto MwSt
@foreach tax in TaxBreakdown
{tax.Category}: {tax.Rate}% {tax.Gross:F2} {tax.Currency} {tax.Net:F2} {tax.Currency} {tax.TaxAmount:F2} {tax.Currency}
@end
@end
{right:Bedient von:} {WaiterName}
{right:Terminal:} {Terminal}
{right:Tisch:} {TableNumber}
#center# {VatNumber} #
@if TerminalReceipt
#center# {TerminalReceipt.ReceiptType} #
#center# {TerminalReceipt.BookingType} #
#center# {TerminalReceipt.PaymentSystem} #
{TerminalReceipt.TransactionNumber}
{TerminalReceipt.TransactionDateTime:dd.MM.yyyy} {right:{TerminalReceipt.TransactionDateTime:HH:mm:ss}}
Trm-Id: {right:{TerminalReceipt.TerminalId}}
AID: {right:{TerminalReceipt.AID}}
Trx. Seq-Cnt: {right:{TerminalReceipt.TransactionSeqCount}}
Trx. Ref-No: {right:{TerminalReceipt.TransactionRefNo}}
Auth. Code: {right:{TerminalReceipt.AuthCode}}
Acq-Id: {right:{TerminalReceipt.AcquirerId}}
EFT {TerminalReceipt.Currency}: {right:{TerminalReceipt.EftAmount:F2}}
Trinkgeld {TerminalReceipt.Currency}: {right:{TerminalReceipt.TipAmount:F2}}
Total-EFT {TerminalReceipt.Currency}: {right:{TerminalReceipt.TotalEftAmount:F2}}
---
@end
#center# {ThankYouMessage} #
#center# {GoodbyeMessageLine1} #
#center# {GoodbyeMessageLine2} #

View File

@@ -0,0 +1,57 @@
#red,big,tall,center# {Title} #
---
#center# {TransactionDateTime:dd-MMM-yy HH:mm} Nr.:{ReceiptNumber} #
#center# {WaiterName} #
#center# {WaiterId} #
#big,bold,center# Tisch: {TableNumber} #
@if SpecialInstruction
#big,bold,center# {SpecialInstruction} #
@end
---
@foreach gang in Gangs
#red,big,tall,center# {gang.Id}. {gang.Name} #
@foreach dish in gang.Dishes
#tall# {dish.Number}x {dish.Name} #
@if dish.Modifications.Removed.count > 0
@foreach removed in dish.Modifications.Removed
#bold,tall# - {removed} #
@end
@end
@if dish.Modifications.Added.count > 0
@foreach added in dish.Modifications.Added
#bold,tall# + {added} #
@end
@end
@if dish.Comment
#bold,tall# Comment: {dish.Comment} #
@end
@end
@end
@if Gangs.count > 0
---
@end
@foreach dish in Dishes
#tall# {dish.Number}x {dish.Name} #
@if dish.Modifications.Removed.count > 0
@foreach removed in dish.Modifications.Removed
#bold,tall# - {removed} #
@end
@end
@if dish.Modifications.Added.count > 0
@foreach added in dish.Modifications.Added
#bold,tall# + {added} #
@end
@end
@if dish.Comment
#bold,tall# Comment: {dish.Comment} #
@end
@end
@if Dishes.count > 0
---
@end

View File

@@ -0,0 +1,57 @@
#red,big,tall,center# {Title} #
---
#center# {TransactionDateTime:dd-MMM-yy HH:mm} Nr.:{ReceiptNumber} #
#center# {WaiterName} #
#center# {WaiterId} #
#big,bold,center# Tisch: {TableNumber} #
@if SpecialInstruction
#big,bold,center# {SpecialInstruction} #
@end
---
@foreach gang in Gangs
#red,big,tall,center# {gang.Id}. {gang.Name} #
@foreach dish in gang.Dishes
#tall# {dish.Number}x {dish.Name} #
@if dish.Modifications.Removed.count > 0
@foreach removed in dish.Modifications.Removed
#bold,tall# - {removed} #
@end
@end
@if dish.Modifications.Added.count > 0
@foreach added in dish.Modifications.Added
#bold,tall# + {added} #
@end
@end
@if dish.Comment
#bold,tall# Comment: {dish.Comment} #
@end
@end
@end
@if Gangs.count > 0
---
@end
@foreach dish in Dishes
#tall# {dish.Number}x {dish.Name} #
@if dish.Modifications.Removed.count > 0
@foreach removed in dish.Modifications.Removed
#bold,tall# - {removed} #
@end
@end
@if dish.Modifications.Added.count > 0
@foreach added in dish.Modifications.Added
#bold,tall# + {added} #
@end
@end
@if dish.Comment
#bold,tall# Comment: {dish.Comment} #
@end
@end
@if Dishes.count > 0
---
@end