1.0.3
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>1.0.2</Version>
|
||||
<Version>1.0.3</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Text.Json;
|
||||
// ============================================================================
|
||||
// FINAL RECEIPT - HTML PRINTER
|
||||
// ============================================================================
|
||||
//var receipt = TestHelpers.BuildSampleFinalReceipt();
|
||||
//var receipt = TestHelpers.BuildSampleFinalReceipt(true);
|
||||
//var serializedReceipt = JsonSerializer.Serialize(receipt, new JsonSerializerOptions { WriteIndented = true });
|
||||
|
||||
//var converter = new FinalReceiptConverter(lineWidth: 48, bigFontLineWidth: 24);
|
||||
|
||||
@@ -40,7 +40,7 @@ public static class TestHelpers
|
||||
|
||||
#region Receipt Builders
|
||||
|
||||
public static FinalReceipt BuildSampleFinalReceipt()
|
||||
public static FinalReceipt BuildSampleFinalReceipt(bool includeTax = true)
|
||||
{
|
||||
var receipt = new FinalReceipt
|
||||
{
|
||||
@@ -64,6 +64,7 @@ public static class TestHelpers
|
||||
ThankYouMessage = "Das Team bedankt sich herzlich für Ihren",
|
||||
GoodbyeMessageLine1 = "Besuch.",
|
||||
GoodbyeMessageLine2 = "Auf Wiedersehen.",
|
||||
IsDebtor = true,
|
||||
SplitPayments = new List<SplitPaymentInfo>
|
||||
{
|
||||
new() { PaymentMethod = "Cash", Amount = 50.00m, Currency = "CHF" },
|
||||
@@ -144,7 +145,8 @@ public static class TestHelpers
|
||||
Description = "Business Lunch Menu Seco",
|
||||
UnitPrice = 44.00m,
|
||||
TotalPrice = 88.00m,
|
||||
TaxCategory = "A"
|
||||
TaxCategory = "A",
|
||||
SubItems = new List<string> { "Tomato Soup", "Grilled Salmon", "Tiramisu" }
|
||||
});
|
||||
|
||||
receipt.Items.Add(new FinalReceiptItem
|
||||
@@ -174,6 +176,8 @@ public static class TestHelpers
|
||||
TaxCategory = "B"
|
||||
});
|
||||
|
||||
if (includeTax)
|
||||
{
|
||||
// Add tax breakdown
|
||||
receipt.TaxBreakdown.Add(new TaxInfo
|
||||
{
|
||||
@@ -194,6 +198,7 @@ public static class TestHelpers
|
||||
TaxAmount = 0.00m,
|
||||
Currency = "CHF"
|
||||
});
|
||||
}
|
||||
|
||||
return receipt;
|
||||
}
|
||||
@@ -247,7 +252,8 @@ public static class TestHelpers
|
||||
Description = "Business Lunch Menu Seco",
|
||||
UnitPrice = 44.00m,
|
||||
TotalPrice = 88.00m,
|
||||
TaxCategory = "A"
|
||||
TaxCategory = "A",
|
||||
SubItems = new List<string> { "Tomato Soup", "Grilled Salmon", "Tiramisu" }
|
||||
});
|
||||
|
||||
receipt.Items.Add(new Inspectron.Epson.PrintServer.Printers.Utils.InvoiceReceipt.ReceiptItem
|
||||
|
||||
@@ -18,6 +18,7 @@ public class FinalReceipt
|
||||
public string PaymentMethod { get; set; }
|
||||
public decimal PaymentAmount { get; set; }
|
||||
public List<TaxInfo> TaxBreakdown { get; set; } = new List<TaxInfo>();
|
||||
public bool IsDebtor { get; set; } = false;
|
||||
public string WaiterName { get; set; }
|
||||
public string Terminal { get; set; }
|
||||
public string TableNumber { get; set; }
|
||||
@@ -35,6 +36,7 @@ public class FinalReceiptItem
|
||||
public decimal UnitPrice { get; set; }
|
||||
public decimal TotalPrice { get; set; }
|
||||
public string TaxCategory { get; set; }
|
||||
public List<string> SubItems { get; set; }
|
||||
}
|
||||
|
||||
public class TaxInfo
|
||||
|
||||
@@ -22,7 +22,10 @@ public class ReceiptConverter
|
||||
commands.Add(new PrintCommand(Center(finalReceipt.Phone, false)));
|
||||
commands.Add(new PrintCommand(""));
|
||||
commands.Add(new PrintCommand(""));
|
||||
|
||||
if (finalReceipt.IsDebtor)
|
||||
{
|
||||
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);
|
||||
commands.Add(new PrintCommand(receiptLine,isBold:true));
|
||||
@@ -41,6 +44,15 @@ public class ReceiptConverter
|
||||
|
||||
string itemLine = quantityDesc + new string(' ', spacesNeeded) + prices;
|
||||
commands.Add(new PrintCommand(itemLine));
|
||||
|
||||
// SubItems
|
||||
if (item.SubItems != null)
|
||||
{
|
||||
foreach (var subItem in item.SubItems)
|
||||
{
|
||||
commands.Add(new PrintCommand($" - {subItem}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
commands.Add(new PrintCommand("")); // Reini
|
||||
@@ -91,6 +103,12 @@ public class ReceiptConverter
|
||||
string taxDetail = ($"{tax.Category}:"+ $"{tax.Rate}%".PadLeft(5)).PadRight(_lineWidth / 4) + $"{tax.Gross:F2} {tax.Currency}".PadLeft(_lineWidth/4)+$"{tax.Net:F2} {tax.Currency}".PadLeft(_lineWidth/4)+$"{tax.TaxAmount:F2} {tax.Currency}".PadLeft(_lineWidth / 4);
|
||||
commands.Add(new PrintCommand(taxDetail));
|
||||
}
|
||||
|
||||
if (finalReceipt.TaxBreakdown.Count(x => x.Category.ToLower()!="d")==0)
|
||||
{
|
||||
commands.Add(new PrintCommand("Nicht mehrwertsteuerpflichtig"));
|
||||
}
|
||||
|
||||
commands.Add(new PrintCommand(""));
|
||||
|
||||
// Footer info
|
||||
@@ -135,6 +153,16 @@ public class ReceiptConverter
|
||||
commands.Add(new PrintCommand(Center(finalReceipt.ThankYouMessage, false)));
|
||||
commands.Add(new PrintCommand(Center(finalReceipt.GoodbyeMessageLine1, false)));
|
||||
commands.Add(new PrintCommand(Center(finalReceipt.GoodbyeMessageLine2, false)));
|
||||
if (finalReceipt.IsDebtor)
|
||||
{
|
||||
commands.Add(new PrintCommand(""));
|
||||
commands.Add(new PrintCommand(""));
|
||||
commands.Add(new PrintCommand(""));
|
||||
commands.Add(new PrintCommand("".PadRight(_lineWidth, '-')));
|
||||
commands.Add(new PrintCommand("Unterschrift"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
return commands;
|
||||
}
|
||||
|
||||
@@ -21,4 +21,5 @@ public class ReceiptItem
|
||||
public decimal UnitPrice { get; set; }
|
||||
public decimal TotalPrice { get; set; }
|
||||
public string TaxCategory { get; set; }
|
||||
public List<string> SubItems { get; set; }
|
||||
}
|
||||
|
||||
@@ -41,6 +41,15 @@ public class ReceiptConverter
|
||||
|
||||
string itemLine = quantityDesc + new string(' ', spacesNeeded) + prices;
|
||||
commands.Add(new PrintCommand(itemLine));
|
||||
|
||||
// SubItems
|
||||
if (item.SubItems != null)
|
||||
{
|
||||
foreach (var subItem in item.SubItems)
|
||||
{
|
||||
commands.Add(new PrintCommand($" - {subItem}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
commands.Add(new PrintCommand(""));
|
||||
|
||||
Reference in New Issue
Block a user