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