-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFiscalReceiptItem.cs
More file actions
65 lines (52 loc) · 1.96 KB
/
FiscalReceiptItem.cs
File metadata and controls
65 lines (52 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
namespace ICLPrinterServer
{
public class FiscalReceiptItem : FiscalReceiptLine
{
public string Item { get; }
public decimal Quantity { get; }
public string MeasUnit { get; }
public decimal Price { get; }
public decimal ExtraPercent { get; }
public FiscalPrinterTaxGroup TaxGroup { get; }
public FiscalReceiptItem (string item, decimal quantity, string measUnit, decimal price,
decimal extraPercent, FiscalPrinterTaxGroup taxGroup)
{
Item = item;
Quantity = Math.Round (quantity, 3);
MeasUnit = measUnit;
Price = Math.Round (price, 2);
ExtraPercent = extraPercent;
TaxGroup = taxGroup;
Total = Math.Round ((Price + Math.Round (Price * extraPercent / 100, 2)) * Quantity, 2);
}
public override void Print (int charsPerLine)
{
Console.ForegroundColor = ConsoleColor.DarkGray;
if (Quantity != 1)
Console.WriteLine ($"{Quantity} x {Price}");
var itemName = Item;
if (itemName.Length > 36) {
Console.WriteLine (itemName.Substring (0, 36));
itemName = itemName.Substring (36);
}
var totalString = $" {Total} {TaxGroupToString (TaxGroup)}";
Console.WriteLine (itemName.PadRight (charsPerLine - totalString.Length, ' ') + totalString);
}
private string TaxGroupToString (FiscalPrinterTaxGroup group)
{
switch (group) {
case FiscalPrinterTaxGroup.A:
return "А";
case FiscalPrinterTaxGroup.B:
return "Б";
case FiscalPrinterTaxGroup.C:
return "В";
case FiscalPrinterTaxGroup.D:
return "Г";
default:
return "Б";
}
}
}
}