diff --git a/scu-it/src/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter/EpsonRTPrinterSCU.cs b/scu-it/src/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter/EpsonRTPrinterSCU.cs index 84ef7fafc..875bcdaaa 100644 --- a/scu-it/src/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter/EpsonRTPrinterSCU.cs +++ b/scu-it/src/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter/EpsonRTPrinterSCU.cs @@ -119,6 +119,11 @@ public override async Task ProcessReceiptAsync(ProcessRequest r return await ProcessPerformReprint(request); } + if (receiptCase == (long) ITReceiptCases.ProtocolUnspecified0x3000) + { + return await ProcessUnspecifiedProtocolReceipt(request); + } + if (receiptCase == (long) ITReceiptCases.Protocol0x0005) { return Helpers.CreateResponse(await PerformProtocolReceiptAsync(request.ReceiptRequest, request.ReceiptResponse)); @@ -292,6 +297,462 @@ public async Task PerformClassicReceiptAsync(ReceiptRequest rec } } + private static string GetAmountString(decimal amount, int length) + { + var amountText = string.Format("{0:0.00}", amount).Replace(".",","); + + if (amountText.Length < length) + { + amountText = new string(' ', length-amountText.Length) + amountText; + } + + return amountText; + } + + private static (List, List) GetChargeItemLines(ChargeItem chargeItem, string vatText, string vatLegendText) + { + var resultItems = new List(); + var resultVatLegend = new List(); + + var isRefundOrVoid = ReceiptCaseHelper.IsVoid(chargeItem) || ReceiptCaseHelper.IsRefund(chargeItem); + var quantity = isRefundOrVoid ? -chargeItem.Quantity : chargeItem.Quantity; + var amount = isRefundOrVoid ? -chargeItem.Amount : chargeItem.Amount; + var description = chargeItem.Description; + + if (quantity == 0) + { + while (description.Length > 0) + { + var desc = description.Length <= 46 ? description : description.Substring(0, 46); + resultItems.Add(new PrintNormal() { Operator = "1", Data = desc }); + description = description.Substring(desc.Length); + } + if (!string.IsNullOrWhiteSpace(chargeItem.ftChargeItemCaseData)) + { + switch (chargeItem.ftChargeItemCase & 0x0000_00F0_0000_0000) + { + case 0x0000_0010_0000_0000: //BMP + { + resultItems.Add(new PrintGraphicCoupon() { Operator = "1", GraphicFormat = PrintGraphicCouponGraphicFormat.BMP, Base64Data = chargeItem.ftChargeItemCaseData }); + break; + } + case 0x0000_0020_0000_0000: //Raster + { + resultItems.Add(new PrintGraphicCoupon() { Operator = "1", GraphicFormat = PrintGraphicCouponGraphicFormat.Raster, Base64Data = chargeItem.ftChargeItemCaseData }); + break; + } + } + } + if (!string.IsNullOrWhiteSpace(chargeItem.ProductBarcode)) + { + switch (chargeItem.ftChargeItemCase & 0x0000_000F_0000_0000) + { + case 0x0000_0000_0000_0000: //EAN13 + { + if ((chargeItem.ProductBarcode.Length != 13) || + !chargeItem.ProductBarcode.All(char.IsDigit)) + { + throw new Exception("EAN 13 code must be 13 numeric chars length!"); + } + resultItems.Add(new PrintBarCode() { Operator = "1", Code = chargeItem.ProductBarcode, CodeType = PrintBarCodeType.EAN13, Height = 128, HRIFont = PrintBarCodeHRIFont.A, HRIPosition = PrintBarCodeHRIPosition.Below, Position = "901", Width = PrintBarCodeWidth.Width3 }); + break; + } + case 0x0000_0001_0000_0000: //EAN8 + { + if ((chargeItem.ProductBarcode.Length != 8) || + !chargeItem.ProductBarcode.All(char.IsDigit)) + { + throw new Exception("EAN 8 code must be 8 numeric chars length!"); + } + resultItems.Add(new PrintBarCode() { Operator = "1", Code = chargeItem.ProductBarcode, CodeType = PrintBarCodeType.EAN8, Height = 128, HRIFont = PrintBarCodeHRIFont.A, HRIPosition = PrintBarCodeHRIPosition.Below, Position = "901", Width = PrintBarCodeWidth.Width3 }); + break; + } + case 0x0000_0002_0000_0000: //UPCA + { + if ((chargeItem.ProductBarcode.Length != 12) || + !chargeItem.ProductBarcode.All(char.IsDigit)) + { + throw new Exception("UPC-A code must be 12 numeric chars length!"); + } + resultItems.Add(new PrintBarCode() { Operator = "1", Code = chargeItem.ProductBarcode, CodeType = PrintBarCodeType.UPCA, Height = 128, HRIFont = PrintBarCodeHRIFont.A, HRIPosition = PrintBarCodeHRIPosition.Below, Position = "901", Width = PrintBarCodeWidth.Width3 }); + break; + } + case 0x0000_0003_0000_0000: //UPCE + { + if ((chargeItem.ProductBarcode.Length != 12) || + !chargeItem.ProductBarcode.All(char.IsDigit) || + !chargeItem.ProductBarcode.StartsWith("0")) + { + throw new Exception("UPC-E code must be 12 numeric chars length and start with 0!"); + } + resultItems.Add(new PrintBarCode() { Operator = "1", Code = chargeItem.ProductBarcode, CodeType = PrintBarCodeType.UPCE, Height = 128, HRIFont = PrintBarCodeHRIFont.A, HRIPosition = PrintBarCodeHRIPosition.Below, Position = "901", Width = PrintBarCodeWidth.Width3 }); + break; + } + case 0x0000_0004_0000_0000: //CODE39 + { + if ((chargeItem.ProductBarcode.Length < 1) || + (chargeItem.ProductBarcode.Length > 34)) + { + throw new Exception("CODE39 code must be 1 to 34 chars length!"); + } + resultItems.Add(new PrintBarCode() { Operator = "1", Code = chargeItem.ProductBarcode, CodeType = PrintBarCodeType.CODE39, Height = 128, HRIFont = PrintBarCodeHRIFont.A, HRIPosition = PrintBarCodeHRIPosition.Below, Position = "901", Width = PrintBarCodeWidth.Width2 }); + break; + } + case 0x0000_0005_0000_0000: //CODE93 + { + if ((chargeItem.ProductBarcode.Length < 1) || + (chargeItem.ProductBarcode.Length > 59)) + { + throw new Exception("CODE93 code must be 1 to 59 chars length!"); + } + resultItems.Add(new PrintBarCode() { Operator = "1", Code = chargeItem.ProductBarcode, CodeType = PrintBarCodeType.CODE93, Height = 128, HRIFont = PrintBarCodeHRIFont.A, HRIPosition = PrintBarCodeHRIPosition.Below, Position = "901", Width = PrintBarCodeWidth.Width2 }); + break; + } + case 0x0000_0006_0000_0000: //CODE128 + { + if ((chargeItem.ProductBarcode.Length < 3) || + (chargeItem.ProductBarcode.Length > 100) || + (!chargeItem.ProductBarcode.StartsWith("{A") && + !chargeItem.ProductBarcode.StartsWith("{B") && + !chargeItem.ProductBarcode.StartsWith("{C"))) + { + throw new Exception("CODE128 code must be 3 to 100 chars length and must start with either {A or {B or {C!"); + } + resultItems.Add(new PrintBarCode() { Operator = "1", Code = chargeItem.ProductBarcode, CodeType = PrintBarCodeType.CODE128, Height = 128, HRIFont = PrintBarCodeHRIFont.A, HRIPosition = PrintBarCodeHRIPosition.Below, Position = "901", Width = PrintBarCodeWidth.Width2 }); + break; + } + case 0x0000_0007_0000_0000: //CODABAR + { + if ((chargeItem.ProductBarcode.Length < 1) || + (chargeItem.ProductBarcode.Length > 47)) + { + throw new Exception("CODABAR code must be 1 to 47 chars length!"); + } + resultItems.Add(new PrintBarCode() { Operator = "1", Code = chargeItem.ProductBarcode, CodeType = PrintBarCodeType.CODABAR, Height = 128, HRIFont = PrintBarCodeHRIFont.A, HRIPosition = PrintBarCodeHRIPosition.Below, Position = "901", Width = PrintBarCodeWidth.Width3 }); + break; + } + case 0x0000_0008_0000_0000: //ITF + { + if ((chargeItem.ProductBarcode.Length < 2) || + (chargeItem.ProductBarcode.Length > 62) || + (chargeItem.ProductBarcode.Length % 2 == 1) || + !chargeItem.ProductBarcode.All(char.IsDigit)) + { + throw new Exception("ITF code must be 2 to 62 numeric chars length!"); + } + resultItems.Add(new PrintBarCode() { Operator = "1", Code = chargeItem.ProductBarcode, CodeType = PrintBarCodeType.ITF, Height = 128, HRIFont = PrintBarCodeHRIFont.A, HRIPosition = PrintBarCodeHRIPosition.Below, Position = "901", Width = PrintBarCodeWidth.Width3 }); + break; + } + case 0x0000_0009_0000_0000: //QRCODE1 + { + resultItems.Add(new PrintBarCode() { Operator = "1", Code = chargeItem.ProductBarcode, CodeType = PrintBarCodeType.QRCODE1, QRCodeAlignment = PrintBarCodeQRCodeAlignment.Centred, QRCodeDataType = PrintBarCodeQRCodeDataType.AlphaNumeric, QRCodeErrorCorrection = 0, QRCodeSize = 4 }); + break; + } + case 0x0000_000A_0000_0000: //QRCODE2 + { + resultItems.Add(new PrintBarCode() { Operator = "1", Code = chargeItem.ProductBarcode, CodeType = PrintBarCodeType.QRCODE2, QRCodeAlignment = PrintBarCodeQRCodeAlignment.Centred, QRCodeDataType = PrintBarCodeQRCodeDataType.AlphaNumeric, QRCodeErrorCorrection = 2, QRCodeSize = 4 }); + break; + } + case 0x0000_000B_0000_0000: //CodeType74 + { + if ((chargeItem.ProductBarcode.Length < 2) || + (chargeItem.ProductBarcode.Length > 96)) + { + throw new Exception("74 code must be 2 to 96 chars length!"); + } + resultItems.Add(new PrintBarCode() { Operator = "1", Code = chargeItem.ProductBarcode, CodeType = PrintBarCodeType.CodeType74, Height = 128, HRIFont = PrintBarCodeHRIFont.A, HRIPosition = PrintBarCodeHRIPosition.Below, Position = "901", Width = PrintBarCodeWidth.Width3 }); + break; + } + case 0x0000_000C_0000_0000: //CodeType75 + { + if ((chargeItem.ProductBarcode.Length != 13) || + !chargeItem.ProductBarcode.All(char.IsDigit)) + { + throw new Exception("75 code must be 13 numeric chars length!"); + } + resultItems.Add(new PrintBarCode() { Operator = "1", Code = chargeItem.ProductBarcode, CodeType = PrintBarCodeType.CodeType75, Height = 128, HRIFont = PrintBarCodeHRIFont.A, HRIPosition = PrintBarCodeHRIPosition.Below, Position = "901", Width = PrintBarCodeWidth.Width3 }); + break; + } + case 0x0000_000D_0000_0000: //CodeType76 + { + if ((chargeItem.ProductBarcode.Length != 13) || + !chargeItem.ProductBarcode.All(char.IsDigit)) + { + throw new Exception("76 code must be 13 numeric chars length!"); + } + resultItems.Add(new PrintBarCode() { Operator = "1", Code = chargeItem.ProductBarcode, CodeType = PrintBarCodeType.CodeType76, Height = 128, HRIFont = PrintBarCodeHRIFont.A, HRIPosition = PrintBarCodeHRIPosition.Below, Position = "901", Width = PrintBarCodeWidth.Width3 }); + break; + } + case 0x0000_000E_0000_0000: //CodeType77 + { + if ((chargeItem.ProductBarcode.Length != 13) || + !chargeItem.ProductBarcode.All(char.IsDigit) || + (!chargeItem.ProductBarcode.StartsWith("0") && + !chargeItem.ProductBarcode.StartsWith("1"))) + { + throw new Exception("77 code must be 13 numeric chars length and start with 0 or 1!"); + } + resultItems.Add(new PrintBarCode() { Operator = "1", Code = chargeItem.ProductBarcode, CodeType = PrintBarCodeType.CodeType77, Height = 128, HRIFont = PrintBarCodeHRIFont.A, HRIPosition = PrintBarCodeHRIPosition.Below, Position = "901", Width = PrintBarCodeWidth.Width3 }); + break; + } + case 0x0000_000F_0000_0000: //CodeType78 + { + if ((chargeItem.ProductBarcode.Length < 2) || + (chargeItem.ProductBarcode.Length > 70)) + { + throw new Exception("78 code must be 2 to 70 chars length!"); + } + resultItems.Add(new PrintBarCode() { Operator = "1", Code = chargeItem.ProductBarcode, CodeType = PrintBarCodeType.CodeType78, Height = 128, HRIFont = PrintBarCodeHRIFont.A, HRIPosition = PrintBarCodeHRIPosition.Below, Position = "901", Width = PrintBarCodeWidth.Width2 }); + break; + } + } + } + } + else if (quantity > 0) + { + if (!string.IsNullOrWhiteSpace(vatLegendText) && !resultVatLegend.Contains(vatLegendText)) + { + resultVatLegend.Add(vatLegendText); + } + + var amountText = GetAmountString(amount, 13); + + description = description.Length <= 38 ? description : description.Substring(0, 38); + if (description.Length <= 25) + { + var desc = description.Length <= 25 ? description + new string(' ', 25 - description.Length) : description.Substring(0, 25); + resultItems.Add(new PrintNormal() { Operator = "1", Data = $"{desc} {vatText} {amountText}" }); + } + else + { + var desc = description.Length <= 25 ? description + new string(' ', 25 - description.Length) : description.Substring(0, 25); + resultItems.Add(new PrintNormal() { Operator = "1", Data = $"{desc}" }); + desc = description.Substring(25); + desc += new string(' ', 25 - desc.Length); + resultItems.Add(new PrintNormal() { Operator = "1", Data = $"{desc} {vatText} {amountText}" }); + } + if (quantity > 1) + { + resultItems.Add(new PrintNormal() { Operator = "1", Data = $" n.{quantity} * {amount / quantity:0.00}" }); + } + } + if (!string.IsNullOrWhiteSpace(chargeItem.ProductBarcode)) + { + //TODO establish the string content + } + + return (resultItems, resultVatLegend); + } + + private static List GetPayItemLines(PayItem payItem) + { + var resultItems = new List(); + + var isRefundOrVoid = ReceiptCaseHelper.IsVoid(payItem) || ReceiptCaseHelper.IsRefund(payItem); + var amount = isRefundOrVoid ? -payItem.Amount : payItem.Amount; + var description = payItem.Description; + var amountText = GetAmountString(amount, 9); + + while (description.Length > 0) + { + var desc = description.Length <= 36 ? description + new string(' ', 36 - description.Length) : description.Substring(0, 36); + resultItems.Add(new PrintNormal() { Operator = "1", Data = $"{desc} {amountText}" }); + if (desc.Length >= description.Length) + { + description = string.Empty; + } + else + { + description = description.Substring(desc.Length); + } + } + + return resultItems; + } + + private static string GetCenteredText(string text, int length) + { + if (text.Length < length) + { + return new string(' ', (length - text.Length) / 2) + text; + } + + return text; + } + + public static PrinterNonFiscal PerformUnspecifiedProtocolReceipt(ReceiptRequest request) + { + var content = new PrinterNonFiscal(); + + content.BeginNonFiscal = new BeginNonFiscal() { Operator = "1" }; + content.EndNonFiscal = new EndNonFiscal() { Operator = "1" }; + content.PrintItems = new List(); + + var vatLegend = new List(); + + var isReceiptLike = request.cbChargeItems.Where(x => x.Amount != 0).Count() > 0 && request.cbPayItems.Where(x => x.Amount != 0).Count() > 0; + + if (isReceiptLike) + { + content.PrintItems.Add(new PrintNormal() { Operator = "1", Data = $"DESCRIZIONE IVA Prezzo(€)" }); + } + + var totalCi = 0M; + var vat = 0M; + + foreach (var ci in request.cbChargeItems) + { + var vatValues = EpsonCommandFactory.GetVatInfo(ci); + + var cil = GetChargeItemLines(ci, vatValues.Item1, vatValues.Item2); + content.PrintItems.AddRange(cil.Item1); + vatLegend.AddRange(cil.Item2); + totalCi += ci.Amount; + vat += ci.Amount * vatValues.Item3 / 100; + } + + if (isReceiptLike) + { + content.PrintItems.Add(new PrintNormal() { Operator = "1", Data = $"" }); + content.PrintItems.Add(new PrintNormal() { Operator = "1", Data = $"Subtotale {GetAmountString(totalCi, 9)}" }); + content.PrintItems.Add(new PrintNormal() { Operator = "1", Data = $"" }); + content.PrintItems.Add(new PrintNormal() { Operator = "1", Data = $"TOTALE COMPLESSIVO {GetAmountString(totalCi, 9)}" }); + content.PrintItems.Add(new PrintNormal() { Operator = "1", Data = $"DI CUI IVA {GetAmountString(vat, 9)}" }); + content.PrintItems.Add(new PrintNormal() { Operator = "1", Data = $"" }); + } + + var totalPi = 0M; + var totalPaid = 0M; + var piAmounts = new Dictionary(); + var piDesc = new Dictionary(); + + foreach (var pi in request.cbPayItems) + { + var pt = EpsonCommandFactory.GetEpsonPaymentType(pi); + + if (!piAmounts.ContainsKey(pt.PaymentType)) + { + piAmounts.Add(pt.PaymentType, 0); + } + + piAmounts[pt.PaymentType] += pi.Amount; + + if (!piDesc.ContainsKey(pi.Description)) + { + piDesc.Add(pi.Description, 0); + } + + piDesc[pi.Description] += pi.Amount; + + if (pt.PaymentType != 5 && pt.PaymentType != 6) + { + totalPaid += pi.Amount; + } + + totalPi += pi.Amount; + } + + if (isReceiptLike) + { + foreach (var piAmount in piAmounts.Keys.OrderBy(x => x)) + { + switch (piAmount) + { + case 0: + { + content.PrintItems.Add(new PrintNormal() { Operator = "1", Data = $"Pagamento contanti {GetAmountString(piAmounts[piAmount], 13)}" }); + break; + } + case 1: + { + content.PrintItems.Add(new PrintNormal() { Operator = "1", Data = $"Assegni {GetAmountString(piAmounts[piAmount], 13)}" }); + break; + } + case 2: + { + content.PrintItems.Add(new PrintNormal() { Operator = "1", Data = $"Pagamento elettronico {GetAmountString(piAmounts[piAmount], 13)}" }); + break; + } + case 3: + { + content.PrintItems.Add(new PrintNormal() { Operator = "1", Data = $"Buono {GetAmountString(piAmounts[piAmount], 13)}" }); + break; + } + case 4: + { + content.PrintItems.Add(new PrintNormal() { Operator = "1", Data = $"Buoni {GetAmountString(piAmounts[piAmount], 13)}" }); + break; + } + case 5: + { + content.PrintItems.Add(new PrintNormal() { Operator = "1", Data = $"Non riscosso {GetAmountString(piAmounts[piAmount], 13)}" }); + break; + } + case 6: + { + content.PrintItems.Add(new PrintNormal() { Operator = "1", Data = $"Sconto a pagare {GetAmountString(piAmounts[piAmount], 13)}" }); + break; + } + } + } + + if (totalPi > totalCi) + { + content.PrintItems.Add(new PrintNormal() { Operator = "1", Data = $"Resto {GetAmountString(totalPi - totalCi, 9)}" }); + totalPaid -= totalPi - totalCi; + } + content.PrintItems.Add(new PrintNormal() { Operator = "1", Data = $"Importo pagato {GetAmountString(totalPaid, 9)}" }); + content.PrintItems.Add(new PrintNormal() { Operator = "1", Data = $"" }); + + foreach (var vatLegendLine in vatLegend) + { + content.PrintItems.Add(new PrintNormal() { Operator = "1", Data = vatLegendLine }); + } + } + + //content.PrintItems.Add(new PrintNormal() { Operator = "1", Data = $"" }); + //content.PrintItems.Add(new PrintNormal() { Operator = "1", Data = GetCenteredText($"{request.cbReceiptMoment.Day:00}-{request.cbReceiptMoment.Month:00}-{request.cbReceiptMoment.Year:0000} {request.cbReceiptMoment.Hour:00}:{request.cbReceiptMoment.Minute:00}", 46)} ); + //content.PrintItems.Add(new PrintNormal() { Operator = "1", Data = GetCenteredText($"DOCUMENTO GESTIONALE N.{request.cbReceiptReference}", 46) }); + + return content; + } + + private async Task ProcessUnspecifiedProtocolReceipt(ProcessRequest request) + { + var error = string.Empty; + try + { + var content = PerformUnspecifiedProtocolReceipt(request.ReceiptRequest); + var data = SoapSerializer.Serialize(content); + _logger.LogDebug("Request content ({receiptreference}): {content}", request.ReceiptRequest.cbReceiptReference, SoapSerializer.Serialize(data)); + var response = await SendRequestAsync(data); + + using var responseContent = await response.Content.ReadAsStreamAsync(); + var printerResponse = SoapSerializer.DeserializeToSoapEnvelope(responseContent); + + if (printerResponse?.Success == false) + { + error = GetErrorInfo(printerResponse?.Code, printerResponse?.Status, printerResponse?.Receipt?.PrinterStatus)?.Info; + } + + await ResetPrinter(); + } + catch (Exception e) + { + error = Helpers.ExceptionInfo(e)?.SSCDErrorInfo?.Info; + } + + if (!string.IsNullOrWhiteSpace(error)) + { + request.ReceiptResponse.SetReceiptResponseErrored(error ?? ""); + } + + return new ProcessResponse + { + ReceiptResponse = request.ReceiptResponse + }; + } + private async Task ProcessPerformReprint(ProcessRequest request) { var referenceZNumber = request.ReceiptResponse.GetSignaturItem(SignatureTypesIT.RTReferenceZNumber)?.Data; diff --git a/scu-it/src/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter/Models/NonFiscal.cs b/scu-it/src/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter/Models/NonFiscal.cs index 2fdeaaf14..16f948c61 100644 --- a/scu-it/src/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter/Models/NonFiscal.cs +++ b/scu-it/src/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter/Models/NonFiscal.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Text; +using System.Xml.Linq; using System.Xml.Serialization; namespace fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter.Models @@ -19,12 +21,19 @@ public class EndNonFiscal public string? Operator { get; set; } } - [XmlType("printNormal")] - public class PrintNormal + [XmlInclude(typeof(PrintBarCode))] + [XmlInclude(typeof(PrintGraphicCoupon))] + [XmlInclude(typeof(PrintNormal))] + public class PrintItem { [XmlAttribute(AttributeName = "operator")] public string? Operator { get; set; } + } + [XmlType("printNormal")] + public class PrintNormal : PrintItem + { + [Description("All four fonts are supported (1 to 4).")] [XmlAttribute(AttributeName = "font")] public int Font { get; set; } @@ -32,17 +41,343 @@ public class PrintNormal public string? Data { get; set; } } + public enum PrintBarCodeType + { + [XmlEnum(Name = "65")] + UPCA = 65, + [XmlEnum(Name = "66")] + UPCE = 66, + [XmlEnum(Name = "67")] + EAN13 = 67, + [XmlEnum(Name = "68")] + EAN8 = 68, + [XmlEnum(Name = "69")] + CODE39 = 69, + [XmlEnum(Name = "70")] + ITF = 70, + [XmlEnum(Name = "71")] + CODABAR = 71, + [XmlEnum(Name = "72")] + CODE93 = 72, + [XmlEnum(Name = "73")] + CODE128 = 73, + [XmlEnum(Name = "74")] + CodeType74 = 74, + [XmlEnum(Name = "75")] + CodeType75 = 75, + [XmlEnum(Name = "76")] + CodeType76 = 76, + [XmlEnum(Name = "77")] + CodeType77 = 77, + [XmlEnum(Name = "78")] + CodeType78 = 78, + [XmlEnum(Name = "91")] + QRCODE1 = 91, + [XmlEnum(Name = "92")] + QRCODE2 = 92 + } + + public enum PrintBarCodeWidth + { + [XmlEnum(Name = "1")] + Width1 = 1, + [XmlEnum(Name = "2")] + Width2 = 2, + [XmlEnum(Name = "3")] + Width3 = 3, + [XmlEnum(Name = "4")] + Width4 = 4, + [XmlEnum(Name = "5")] + Width5 = 5, + [XmlEnum(Name = "6")] + Width6 = 6 + } + + public enum PrintBarCodeQRCodeAlignment + { + [XmlEnum(Name = "0")] + LeftAligned = 0, + [XmlEnum(Name = "1")] + Centred = 1, + [XmlEnum(Name = "2")] + RightAligned = 2 + } + + public enum PrintBarCodeHRIPosition + { + [XmlEnum(Name = "0")] + Disabled = 0, + [XmlEnum(Name = "1")] + Above = 1, + [XmlEnum(Name = "2")] + Below = 2, + [XmlEnum(Name = "3")] + AboveAndBelow = 3 + } + + public enum PrintBarCodeQRCodeDataType + { + [XmlEnum(Name = "0")] + AlphaNumeric = 0, + [XmlEnum(Name = "9")] + Binary = 9 + } + + public enum PrintBarCodeHRIFont + { + [XmlEnum(Name = "A")] + A, + [XmlEnum(Name = "B")] + B, + [XmlEnum(Name = "C")] + C + } + + public enum PrintBarCodeQRCodeErrorCorrection + { + [XmlEnum(Name = "0")] + Low = 0, + [XmlEnum(Name = "1")] + MediumLow = 1, + [XmlEnum(Name = "2")] + MediumHigh = 2, + [XmlEnum(Name = "3")] + High = 3 + } + + [XmlType("printBarCode")] + public class PrintBarCode : PrintItem + { + [Description("Barcode or QR code standard.")] + [XmlAttribute(AttributeName = "codeType")] + public PrintBarCodeType CodeType { get; set; } + + [Description("Defines the starting position from the left margin (range 0 to 511). Three special values can also be used: 900 = Left aligned; 901 = Centred; 902 = Right aligned. This attribute is not used with QR codes and can therefore be omitted.")] + [XmlAttribute(AttributeName = "position")] + public string? Position { get; set; } + + [Description("Print dot width of each distinct bar (range 1 to 6). This attribute is not used with QR codes and can therefore be omitted. Please note that not all readers are able to read barcodes with a 1 dot width.")] + [XmlIgnore] + public PrintBarCodeWidth? Width { get; set; } + + [XmlAttribute(AttributeName = "width")] + public string? WidthSerialized + { + get => Width.HasValue ? ((int) Width.Value).ToString() : null; + set + { + if (int.TryParse(value, out var intValue)) + { + Width = (PrintBarCodeWidth) intValue; + } + else + { + Width = null; + } + } + } + + [Description("Height of the bar code measured in print dots (range 1 to 255). This attribute is not used with QR codes and can therefore be omitted.")] + [XmlIgnore] + public int? Height { get; set; } + + [XmlAttribute(AttributeName = "height")] + public string? HeightSerialized + { + get => Height.HasValue ? ((int) Height.Value).ToString() : null; + set + { + if (int.TryParse(value, out var intValue)) + { + Height = intValue; + } + else + { + Height = null; + } + } + } + + [Description("QR code position.")] + [XmlIgnore] + public PrintBarCodeQRCodeAlignment? QRCodeAlignment { get; set; } + + [XmlAttribute(AttributeName = "qRCodeAlignment")] + public string? QRCodeAlignmentSerialized + { + get => QRCodeAlignment.HasValue ? ((int) QRCodeAlignment.Value).ToString() : null; + set + { + if (int.TryParse(value, out var intValue)) + { + QRCodeAlignment = (PrintBarCodeQRCodeAlignment) intValue; + } + else + { + QRCodeAlignment = null; + } + } + } + + [Description("QR code dimension (range 1 to 16).")] + [XmlIgnore] + public int? QRCodeSize { get; set; } + + [XmlAttribute(AttributeName = "qRCodeSize")] + public string? QRCodeSizeSerialized + { + get => QRCodeSize.HasValue ? ((int) QRCodeSize.Value).ToString() : null; + set + { + if (int.TryParse(value, out var intValue)) + { + QRCodeSize = intValue; + } + else + { + QRCodeSize = null; + } + } + } + + [Description("Selects one of three ways to print the alphanumeric representation of the barcode or to disable it altogether. This attribute is not used with QR codes and can therefore be omitted.")] + [XmlIgnore] + public PrintBarCodeHRIPosition? HRIPosition { get; set; } + + [XmlAttribute(AttributeName = "hRIPosition")] + public string? HRIPositionSerialized + { + get => HRIPosition.HasValue ? ((int) HRIPosition.Value).ToString() : null; + set + { + if (int.TryParse(value, out var intValue)) + { + HRIPosition = (PrintBarCodeHRIPosition) intValue; + } + else + { + HRIPosition = null; + } + } + } + + [Description("Indicates whether the QR code data is alphanumeric or binary. When binary is chosen, the code attribute value is represented by pairs of hexadecimal digits. For example, HELLO = 48454C4C4F.")] + [XmlIgnore] + public PrintBarCodeQRCodeDataType? QRCodeDataType { get; set; } + + [XmlAttribute(AttributeName = "qRCodeDataType")] + public string? QRCodeDataTypeSerialized + { + get => QRCodeDataType.HasValue ? ((int) QRCodeDataType.Value).ToString() : null; + set + { + if (int.TryParse(value, out var intValue)) + { + QRCodeDataType = (PrintBarCodeQRCodeDataType) intValue; + } + else + { + QRCodeDataType = null; + } + } + } + + [Description("The font to be used for the HRI string. This attribute is not used with QR codes and can therefore be omitted.")] + [XmlIgnore] + public PrintBarCodeHRIFont? HRIFont { get; set; } + + [XmlAttribute(AttributeName = "hRIFont")] + public string? HRIFontSerialized + { + get => HRIFont.HasValue ? HRIFont.Value.ToString() : null; + set + { + if (int.TryParse(value, out var intValue)) + { + HRIFont = (PrintBarCodeHRIFont) intValue; + } + else + { + HRIFont = null; + } + } + } + + [Description("The level of error correction to employ (range 0 to 3).")] + [XmlIgnore] + public int? QRCodeErrorCorrection { get; set; } + + [XmlAttribute(AttributeName = "qRCodeErrorCorrection")] + public string? QRCodeErrorCorrectionSerialized + { + get => QRCodeErrorCorrection.HasValue ? ((int) QRCodeErrorCorrection.Value).ToString() : null; + set + { + if (int.TryParse(value, out var intValue)) + { + QRCodeErrorCorrection = intValue; + } + else + { + QRCodeErrorCorrection = null; + } + } + } + + [Description("Represents the barcode or QR code itself. QR codes up to 256 characters can be printed. If the qRCodeDataType attribute indicates a binary representation, this attribute value is represented by pairs of hexadecimal digits. For example, HELLO = 48454C4C4F.")] + [XmlAttribute(AttributeName = "code")] + public string Code { get; set; } + } + + public enum PrintGraphicCouponGraphicFormat + { + [XmlEnum(Name = "B")] + BMP, + [XmlEnum(Name = "R")] + Raster + } + + [XmlType("printGraphicCoupon")] + public class PrintGraphicCoupon : PrintItem + { + [Description("The original image format.")] + [XmlIgnore] + public PrintGraphicCouponGraphicFormat? GraphicFormat { get; set; } + + [XmlAttribute(AttributeName = "graphicFormat")] + public string? GraphicFormatSerialized + { + get => GraphicFormat.HasValue ? ((int) GraphicFormat.Value).ToString() : null; + set + { + if (int.TryParse(value, out var intValue)) + { + GraphicFormat = (PrintGraphicCouponGraphicFormat) intValue; + } + else + { + GraphicFormat = null; + } + } + } + + [Description("The binary data must be supplied in the base64 format and is passed as element data after the attributes rather than being a specific attribute value. The sub-element cannot be auto closed with /> and must therefore contain the closing sub-element name prepended with /. Do not use this command to print coupons without base64 data – It is not meant to be used with files uploaded via the upload.cgi service. The maximum Base 64 data size is 26668 bytes which corresponds with an unencoded limit of 20000 bytes.")] + [XmlText] + public string Base64Data { get; set; } + } + [XmlType("printerNonFiscal")] public class PrinterNonFiscal { [XmlElement(ElementName = "beginNonFiscal")] public BeginNonFiscal BeginNonFiscal { get; set; } = new BeginNonFiscal(); - [XmlElement(ElementName = "printNormal")] - public List PrintNormals { get; set; } = new List(); + [XmlElement(ElementName = "printNormal", Type = typeof(PrintNormal))] + [XmlElement(ElementName = "printBarCode", Type = typeof(PrintBarCode))] + [XmlElement(ElementName = "printGraphicCoupon", Type = typeof(PrintGraphicCoupon))] + public List PrintItems { get; set; } = new List(); [XmlElement(ElementName = "endNonFiscal")] public EndNonFiscal EndNonFiscal { get; set; } = new EndNonFiscal(); - } } diff --git a/scu-it/src/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter/Utilities/EpsonCommandFactory.cs b/scu-it/src/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter/Utilities/EpsonCommandFactory.cs index 0bcb18797..ef28b1d2f 100644 --- a/scu-it/src/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter/Utilities/EpsonCommandFactory.cs +++ b/scu-it/src/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter/Utilities/EpsonCommandFactory.cs @@ -503,7 +503,7 @@ public static int GetVatGroup(this ChargeItem chargeItem) 0x1 => _vatRateDeduction1, // 10% 0x2 => _vatRateDeduction2, // 4% 0x3 => _vatRateBasic, // 22% - 0x4 => _vatRateSuperReduced1, // ? + 0x4 => _vatRateSuperReduced1, // 5% 0x5 => _vatRateSuperReduced2, // ? 0x6 => _vatRateParking, // ? 0x7 => _vatRateZero, // ? @@ -511,6 +511,37 @@ public static int GetVatGroup(this ChargeItem chargeItem) _ => _vatRateUnknown // ? }; } + + public static (string, string, decimal) GetVatInfo(this ChargeItem chargeItem) + { + if ((chargeItem.ftChargeItemCase & 0xF) == 0x8) + { + return (chargeItem.ftChargeItemCase & 0xF000) switch + { + 0x8000 => (" EE*", "*EE = Esclusa", 0), + 0x2000 => (" NS*", "*NS = Non soggetta", 0), + 0x1000 => (" NI*", "*NI = Non imponibile", 0), + 0x3000 => (" ES*", "*ES = Esente", 0), + 0x4000 => (" RM*", "*RM = Regime del margine", 0), + 0x5000 => (" AL*", "*AL = Operazione non IVA", 0), + _ => (" ", "", 0) // ? + }; + } + + return (chargeItem.ftChargeItemCase & 0xF) switch + { + 0x0 => (" ", "", 0), // 0 ??? + 0x1 => ("10,00%", "", 10), // 10% + 0x2 => (" 4,00%", "", 4), // 4% + 0x3 => ("22,00%", "", 22), // 22% + 0x4 => (" 5,00%", "", 5), // 5% + 0x5 => (" ", "", 0), // ? + 0x6 => (" ", "", 0), // ? + 0x7 => (" ", "", 0), // ? + 0x8 => (" ", "", 0), // ? + _ => (" ", "", 0) // ? + }; + } } } diff --git a/scu-it/test/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter.UnitTest/ReceiptExamples.cs b/scu-it/test/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter.UnitTest/ReceiptExamples.cs index bcc9f4111..0dba3ed5c 100644 --- a/scu-it/test/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter.UnitTest/ReceiptExamples.cs +++ b/scu-it/test/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter.UnitTest/ReceiptExamples.cs @@ -84,7 +84,7 @@ public static ReceiptRequest GetDailyClosing() public static ReceiptRequest GetTakeAway_Delivery_Cash() { - var current_moment = DateTime.UtcNow; + var current_moment = DateTime.UtcNow.ToString("s"); var receipt = $$""" { "ftCashBoxID": "00000000-0000-0000-0000-000000000000", @@ -136,7 +136,7 @@ public static ReceiptRequest GetTakeAway_Delivery_Cash() "Amount": 10, "VATRate": 0, "VATAmount": 0, - "ftChargeItemCase": 5283883447186624532, + "ftChargeItemCase": 5283883447184556040, "Description": "TakeAway - Delivery - Item VAT NI", "Moment": "{{current_moment}}" }, @@ -145,7 +145,7 @@ public static ReceiptRequest GetTakeAway_Delivery_Cash() "Amount": 10, "VATRate": 0, "VATAmount": 0, - "ftChargeItemCase": 5283883447186628628, + "ftChargeItemCase": 5283883447184531464, "Description": "TakeAway - Delivery - Item VAT NS", "Moment": "{{current_moment}}" }, @@ -154,7 +154,7 @@ public static ReceiptRequest GetTakeAway_Delivery_Cash() "Amount": 10, "VATRate": 0, "VATAmount": 0, - "ftChargeItemCase": 5283883447186632724, + "ftChargeItemCase": 5283883447184527368, "Description": "TakeAway - Delivery - Item VAT ES", "Moment": "{{current_moment}}" }, @@ -163,7 +163,7 @@ public static ReceiptRequest GetTakeAway_Delivery_Cash() "Amount": 10, "VATRate": 0, "VATAmount": 0, - "ftChargeItemCase": 5283883447186636820, + "ftChargeItemCase": 5283883447184535560, "Description": "TakeAway - Delivery - Item VAT RM", "Moment": "{{current_moment}}" }, @@ -172,7 +172,7 @@ public static ReceiptRequest GetTakeAway_Delivery_Cash() "Amount": 10, "VATRate": 0, "VATAmount": 0, - "ftChargeItemCase": 5283883447186640916, + "ftChargeItemCase": 5283883447184539656, "Description": "TakeAway - Delivery - Item VAT AL", "Moment": "{{current_moment}}" }, @@ -181,7 +181,7 @@ public static ReceiptRequest GetTakeAway_Delivery_Cash() "Amount": 10, "VATRate": 0, "VATAmount": 0, - "ftChargeItemCase": 5283883447186653204, + "ftChargeItemCase": 5283883447184543752, "Description": "TakeAway - Delivery - Item VAT EE", "Moment": "{{current_moment}}" } @@ -700,6 +700,349 @@ public static ReceiptRequest FoodBeverage_CashAndVoucher() ], "ftReceiptCase": 5283883447184523265 } +"""; + return JsonConvert.DeserializeObject(receipt); + } + + public static ReceiptRequest NonFiscal() + { + var current_moment = DateTime.UtcNow; + var receipt = $$""" +{ + "ftCashBoxID": "00000000-0000-0000-0000-000000000000", + "ftPosSystemId": "00000000-0000-0000-0000-000000000000", + "cbTerminalID": "00010001", + "cbReceiptReference": "0001-0006", + "cbUser": "user1234", + "cbReceiptMoment": "{{current_moment}}", + "cbChargeItems": [ + { + "Quantity": 0, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883447184523265, + "ProductBarcode": "4015000073615", + "Description": "Food/Beverage - Item VAT 10%", + "Moment": "{{current_moment}}" + }, + { + "Quantity": 0, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883451479490561, + "ProductBarcode": "12345678", + "Description": "Food/Beverage - Item VAT 10%", + "Moment": "{{current_moment}}" + }, + { + "Quantity": 0, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883455774457857, + "ProductBarcode": "123456789012", + "Description": "Food/Beverage - Item VAT 10%", + "Moment": "{{current_moment}}" + }, + { + "Quantity": 0, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883460069425153, + "ProductBarcode": "012345654565", + "Description": "Food/Beverage - Item VAT 10%", + "Moment": "{{current_moment}}" + }, + { + "Quantity": 0, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883464364392449, + "ProductBarcode": "CODE39VALUE", + "Description": "Food/Beverage - Item VAT 10%", + "Moment": "{{current_moment}}" + }, + { + "Quantity": 0, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883468659359745, + "ProductBarcode": "CODE93VALUE", + "Description": "Food/Beverage - Item VAT 10%", + "Moment": "{{current_moment}}" + }, + { + "Quantity": 0, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883472954327041, + "ProductBarcode": "{BCODE128VALUE", + "Description": "Food/Beverage - Item VAT 10%", + "Moment": "{{current_moment}}" + }, + { + "Quantity": 0, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883477249294337, + "ProductBarcode": "A12345B", + "Description": "Food/Beverage - Item VAT 10%", + "Moment": "{{current_moment}}" + }, + { + "Quantity": 0, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883481544261633, + "ProductBarcode": "1234567890", + "Description": "Food/Beverage - Item VAT 10%", + "Moment": "{{current_moment}}" + }, + { + "Quantity": 0, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883485839228929, + "ProductBarcode": "1234567890", + "Description": "Food/Beverage - Item VAT 10%", + "Moment": "{{current_moment}}" + }, + { + "Quantity": 0, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883490134196225, + "ProductBarcode": "https://docs.fiskaltrust.cloud/docs/poscreators/middleware-doc/italy/reference-tables/ftreceiptcase", + "Description": "Food/Beverage - Item VAT 10%", + "Moment": "{{current_moment}}" + }, + { + "Quantity": 0, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883494429163521, + "ProductBarcode": "CUSTOMTYPE74", + "Description": "Food/Beverage - Item VAT 10%", + "Moment": "{{current_moment}}" + }, + { + "Quantity": 0, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883498724130817, + "ProductBarcode": "0123456789012", + "Description": "Food/Beverage - Item VAT 10%", + "Moment": "{{current_moment}}" + }, + { + "Quantity": 0, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883503019098113, + "ProductBarcode": "0123456789012", + "Description": "Food/Beverage - Item VAT 10%", + "Moment": "{{current_moment}}" + }, + { + "Quantity": 0, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883507314065409, + "ProductBarcode": "1123456789012", + "Description": "Food/Beverage - Item VAT 10%", + "Moment": "{{current_moment}}" + }, + { + "Quantity": 0, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883511609032705, + "ProductBarcode": "0123456789ABCDabcd", + "Description": "Food/Beverage - Item VAT 10%", + "Moment": "{{current_moment}}" + }, + { + "Quantity": 0, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883515904000001, + "ftChargeItemCaseData": "VEhJUyBJUyBBIFRFU1QgSU1BR0UNCk1BREUgQlkgVEVYVA==", + "Description": "BMP", + "Moment": "{{current_moment}}" + }, + { + "Quantity": 0, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883584623476737, + "ftChargeItemCaseData": "G0AbMygbYQEddjAADQAyAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAcoAAAAAAAAAAAAAAAIB4AAAAAAAAAAAAAACaEAAAAAAAAAAAAAAGLYgAAAAAAAAAAAAAAmTIAAAAAAAAAAAAAARBJAAAAAAAAAAAAAACgKYAAAAAAAAAAAAABMDSAAAAAAAAAAAAAARMEAAAAAAAAAAAAAAKRAQAAAAAAAAAAAAABKDkAAAAAAAAAAAAAAJOjADiACAACAAAAAABMsoB5wAwAAwAAAAAAQkQAYYAcAAMYAAAAYGAMAGAADAADGAAAAGA6sAD8h4xHwz5JjDz4B1AA/4+Y5+c+eYz8+AAAAGHMDMBjOHmMwOAAAABhjA2AYxhhjGBgAAAAYY+Zg+cYYYx8YAAAAGGDjYdjGGGMHGAAAABhgM3OcxjhnAxgwAAAYc+cxmccYfzsecAAAGGPiGfjHmH0/HiAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAARAAAAAAAAAAAAACIAEQAAAAAAAAAAAAAiABAEAAAAAAAAAAAAJ48RHAAAAAAAAAAAACIBEQIAAAAAAAAAAAAiAREBAAAAAAAAAAAAIgUREgAAAAAAAAAAACIZETIAAAAAAAAAAAAiERMjAAAAAAAAAAAAIRMREgAAAAAAAAAAAACEEAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAChshABtFARshECAgICAgICAgICAgICAgICAgICAgICAgTUYgICAgICAgICAgICAgICAgICAgICAgIAobIQAgICAgICAgICAgICAgICBQaWF6emEgRHVvbW8gMjAvQyAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgMjAxMDAgTWlsYW5vICAgICAgICAgICAgICAgICAgChtFASAgICAgICAgICAgICBET0NVTUVOVE8gQ09NTUVSQ0lBTEUgICAgICAgICAgICAgIAobIQAbRQEgICAgICAgICAgICBkaSB2ZW5kaXRhIG8gcHJlc3RhemlvbmUgICAgICAgICAgICAKGyEAChtFAURFU0NSSVpJT05FICAgICAgICAgICAgICAgICAgIElWQSAgICAgIFByZXp6byjVKQobIQBGb29kL0JldmVyYWdlIC0gSXRlbSBWQVQgMTAlICAgICAgIDEwJSAgICAgICAgMTAKNywwMApGb29kL0JldmVyYWdlIC0gSXRlbSBWQVQgMTAlICAgICAgIDEwJSAgICAgICAgMTAKNywwMAoKG0UBGyEQVE9UQUxFIENPTVBMRVNTSVZPICAgICAgICAgICAgICAgICAgICAgICAgMjE0LDAwChshABtFARshEGRpIGN1aSBJVkEgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAxOSw0NQobIQAKUGFnYW1lbnRvIGNvbnRhbnRlICAgICAgICAgICAgICAgICAgICAgICAgMjE0LDAwCkltcG9ydG8gcGFnYXRvICAgICAgICAgICAgICAgICAgICAgICAgICAgIDIxNCwwMAoKICAgICAgICAgICAgICAgMzEtMTItMjAyNCAxMjo0NQ0gICAgICAgICAgICAgICAgCiAgICAgICAgICAgIERPQ1VNRU5UTyBOLiAwMDE0LTAwMDENICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgIENhc3NhIEZNIFRlc3QNICAgICAgICAgICAgICAgICAKCgoKCh1WABshAA==", + "Description": "Raster", + "Moment": "{{current_moment}}" + } + ], + "cbPayItems": [], + "ftReceiptCase": 5283883447184535552 +} +"""; + return JsonConvert.DeserializeObject(receipt); + } + public static ReceiptRequest NonFiscal2() + { + var current_moment = DateTime.UtcNow; + var receipt = $$""" +{ + "ftCashBoxID": "00000000-0000-0000-0000-000000000000", + "ftPosSystemId": "00000000-0000-0000-0000-000000000000", + "cbTerminalID": "00010001", + "cbReceiptReference": "0001-0006", + "cbUser": "user1234", + "cbReceiptMoment": "{{current_moment}}", + "cbChargeItems": [ + { + "Quantity": 0, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883515904000001, + "ftChargeItemCaseData": "VEhJUyBJUyBBIFRFU1QgSU1BR0UNCk1BREUgQlkgVEVYVA==", + "Description": "BMP", + "Moment": "{{current_moment}}" + }, + { + "Quantity": 0, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883515904000001, + "ftChargeItemCaseData": "Qk3ePwAAAAAAAJYAAAB8AAAAWgAAAC0AAAABACAAAwAAAAAAAADXDQAA1w0AAAAAAAAAAAAAAAD/AAD/AAD/AAAAAAAA/yBuaVcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/wAAAAD/AAAAAP8A/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////v7+/+jo6P7d3d3+///////////19fX/xsbG/rGxsf7l5eX+/////+jo6P60tLT+wcHB/tvb2/7g4OD/+Pj4//v7+/7T09P+9/f3//39/f/j4+P+4+Pj///////8/Pz/z9DQ/rGxsf7Pz8/+4ODg/uTk5P7//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////f39/7y8vPyUlJT///////////++vr7+eHh4/q2urv3i4uL++Pj4/4OEhP6Wl5f+tra2/nV1df6IiIj/8PDw//Ly8v5kZGT+6urq//r6+v+tra3+ra2t///////Nzc3+dnZ2/rCwsP6lpaX+XFxc/rGxsf3//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////f39/7m5ufyPj4////////////+mpqb/q6ur/vf39///////7Ozs/15fX/7k5OT+/////8bGxv2IiYn+7u7u//Ly8v5ZWVn+6enp//r6+v+pqan+qqqq//////+rq6v+o6Oj/vX19f/4+Pj/mpqa/6ioqPz//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////f39/7q6uvyRkZH///////////+np6f/rq6u/vr6+v//////9/f3/4KCgv6MjIz9u7y8+4uLi/yGhob+8PDw//Ly8v5eXl7+6enp//r6+v+qqqr+q6ur///////Nzc3+bm9v/qioqPy2trb7b29v/q6urvz//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////f39/7q6uvyRkZH///////////+oqKj/rq6u/vv7+////////////+7u7v7AwMD+u7u7/JGRkfyGh4f+7+/v//Ly8v5eXl7+6enp//r6+v+qqqr+q6ur///////+/v7/2dra/rm5uf24uLj8dXV1/qysrPz//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////f39/7q6uvyRkZH///////////6pqan/r6+v/vv7+/7//////////////////////////87Ozv6IiIj+7u7u//Ly8v5eXl7+6enp//r6+v+qqqr+qqqq////////////////////////////np6e/qmpqf3//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////f39/7q6uvyUlJT//////9vb2/x0dHT+gYGB/bm5ufvm5ub9/Pz8/9HR0f7BwcH+yMjI/omJif6mpqb++Pj4//Hx8f5eXl7+6enp//r6+v+nqKj+p6en///////s7Oz+xMTE/sbGxv7AwMD+aGlp/tHR0f7//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////f39/7q6uvyUlZX//////9XV1f1oaGj+d3h4/a+vr/zh4eH9/Pz8/87Ozv6qqqr+pqam/ri4uP7t7e3///////Dw8P5eXl7+6enp//39/f/f39/93t7e/f/////t7e3+urq6/qeoqP2oqKj+y8vL/vv7+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////f39/7i4uPyLi4v///////////6rq6v+r6+v/v39/f7////////////////+/v7//Pz8//////////////////Dw8P5dXV3+6enp//39/f/f4OD939/f/f////////////////z8/P/9/f3//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////f39/8XFxf2kpKT////////////s7Oz+6+vr/v7+/v////////////////////////////////////////////Dw8P5OT0/+6Ojo//r6+v+qqqr+qaqq//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////j4+P/19fX///////////////////////////////////////////////////////////////////////v7+//Z2dn+9vb2//7+/v/r6ur/6urq///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+/v7//f39//7+/v/////////////////+/v7//f39//7+/v////////////z8/P/6+vr/+vr6//////////////////7+/v/9/f3+/v7+/////////////v7+//39/f/9/f3////////////6+vr//f39///////+/v7//v7+///////+/v7//f39//7+/v/////////////////9/f3/+fn5//z8/P///////v7+//39/f/+/v7///////////////////////v7+//7+/v//////////////////f39/////////////v7+//r6+v/5+fn//f39///////////////////////9/f3/+fn5//z8/P////////////7+/v/9/f3//v7+//////////////////////////////////////////////////////////////////////////////////7+/v/j4+P9urq6/dXV1f35+fn///////7+/v/Ozs79wMDA/d7e3v37+/v/2NjY/rm5uf6pqan+ra2t/s7Ozv739/f//f39/9LS0v2/v7/839/f/v/////x8fH+ycnJ/bu7u/3r6+v++vr6/8zMzP6qqqr+wcHB/tjY2P7Gxsb9z8/P/fr6+v/i4uL+v7+//c3Nzf38/Pz//////+vr6/69vb3+qamp/ru7u/74+Pj/4ODg/L6+vv3S0tL8/f39/v//////////4uLi/rGxsf2ysrL9zMzM/ubm5v/Ozs7+y8vL/fb29v/p6en+wsLC/q6urv6oqKj+vr6+/ujo6P7//////////+zs7P6+vr7+qKio/ri4uP719fX//Pz8/83Nzf7BwcH94+Pj/v////////////////////////////////////////////////////////////////////////////////z8/P64uLj7AAAA/oeHh/7x8fH+//////z8/P5mZmb9AAAA/6ioqPvz8/P+cXFx/QAAAP8vLy/+AAAA/wAAAP+9vb3++Pj4/3d3d/4AAAD+ra2t//////+2trb+AAAA/zw8PP7r6+v+1tbW/gAAAP8AAAD/NDQ0/igoKP4AAAD/cHBw/vT09P+1tbX/AAAA/mNjY//6+vr/+Pj4/pycnP4AAAD/AAAA/yQkJP7y8vL+r6+v/AAAAP92dnb9+fn5/f/////39/f+g4OD/gAAAP8AAAD/AAAA/kdHR/4AAAD+ZWVl/+zs7P+1tbX9AAAA/hsbG/4VFRX/AAAA/3t7e/709PT++vr6/6Kiov4AAAD/AAAA/wAAAP7s7Oz++Pj4/1tbW/8AAAD+s7Oz//////////////////////////////////////////////////////////////////////////////////39/f69vb38AAAA/5CQkP/y8vL///////39/f51dXX+BwcH/6ysrPv9/f3+1NTU/srKyv7f39/+mpqa/gMDA/96enr++Pj4/4SEhP8AAAD/urq6/+3t7f5sbGz/AAAA/8TExP7+/v7/qKio/QAAAP9/f3/+29vb/ZmZmf4AAAD/fX19/vX19f+5ubn/AAAA/3R0dP/8/Pz/7Ozs/nx8fP4AAAD/np6e/dPT0/78/Pz+srKy/AAAAP+Dg4P++fn5/v/////n5+f+aGho/wAAAP+EhIT+mpqa/k1NTf4AAAD/c3Nz/+rq6v/l5eX+yMjI/tjY2P7Nzc39Hh4e/kRERP/b29v+8fHx/oODg/0AAAD/m5ub/tHR0f78/Pz++fn5/3R0dP4JCQn/vLy8//////////////////////////////////////////////////////////////////////////////////39/f69vb38AAAA/5CQkP7y8vL///////39/f51dXX+CAgI/6urq/v///////////f39/7c3Nz9ioqK/gAAAP92dnb++Pj4/4SEhP8AAAD/sLCw/7a2tv4AAAD/fX19/vLy8v7/////tLS0/QAAAP9hYWH/s7Oz/4SEhP4AAAD/fX19/vX19f+5ubn/AAAA/3R0dP/8/Pz/7e3t/n5+fv4AAAD/zs7O/P//////////sbGx/AAAAP+Dg4P++fn5/v/////l5eX/aGho/wAAAP/U1NT+9/f3/r+/v/wAAAD/cnJy/+bm5v///////////ubm5v69vb3+ExMT/0NDQ//Z2dn+8vLy/YSEhP0AAAD/ycnJ/v///////////f39/97e3v7V1dX+7Ozs/v////////////////////////////////////////////////////////////////////////////////39/f69vb38AAAA/5CQkP7y8vL///////39/f51dXX+BgYG/6urq/v////+09PT/nR0dP5DQ0P+AAAA/wAAAP7AwMD++fn5/4ODg/8hISH/kpKS/n9/f/4AAAD/wsLC/v7+/v//////6+vr/omJif5DQ0P/MTEx/yUlJf8AAAD/fX19/vX19f+5ubn/AAAA/3R0dP/8/Pz/7e3t/n5+fv4AAAD/ysrK/P////7/////sbGx/AAAAP+Hh4f+/Pz8/v/////l5eX/aGho/wAAAP/b29v//////9jY2P0AAAD/cnJy/+np6f/u7u7/mJiY/1hYWP8AAAD/AAAA/4WFhf319fX+8PDw/YSEhP0AAAD/xcXF/v7+/v////////////////////////////////////////////////////////////////////////////////////////////////////////////7+/v7AwMD8AAAA/5OTk//09PT///////////54eHj+BgYG/62trfv4+Pj+k5OT/gAAAP94eHj+wMDA/uXl5f77+/v/+fn5/4ODg/8AAAD/qqqq/6mpqf4AAAD/k5OT/vf39/////////////b29v/w8PD/8vLy/rCwsP0AAAD+fHx8/vX19f+5ubn/AAAA/3R0dP/7+/v/7u7u/oGBgf4AAAD/zc3N/P////7/////sbGx/AAAAP9kZGT+4ODg/f/////m5ub/aGho/wAAAP/Y2Nj//////9XV1f8AAAD/c3Nz/+3t7f/ExMT+AAAA/zw8PP6tra3+19fX/vT09P//////8PDw/YeHh/0AAAD/ycnJ/v///////////////////////////////////////////////////////////////////////////////////////////////////////////v7+/+Tk5P6enp78AAAA/3l5ef7R0dH+3d3d/9jY2P5iYmL+BgYG/66urvv19fX+h4eH/gAAAP+5ubn+8PDw/uXl5f3w8PD++fn5/4ODg/8AAAD/u7u7/+Li4v5aWlr+AAAA/tTU1P7/////+Pj4/9nZ2f7o6Oj+5+fn/ZiYmP4AAAD/hISE/vb29v+5ubn/AAAA/3d3d//29vb/0dHR/2RkZP4AAAD/qKio/dnZ2f/8/Pz/srKy/AAAAP8AAAD/Ojo6/7i4uP3g4OD+b29v/wAAAP/Y2Nj//////9XV1f8AAAD/c3Nz/+7u7v+9vb3+AAAA/3p6ev3q6ur+6+vr/ubm5v76+vr+0tLS/mlpaf4AAAD/paWl/tjY2P/4+Pj//////////////////////////////////fv5/u7izf707eD+///+////////////////////////////////////////////+fn5/4eHh/0AAAD/BAQE/wkJCf8VFRX/GBgY/xYWFv8DAwP/EBAQ/qurq/v8/Pz+qKio/gAAAP8AAAD/GBgY/wAAAP+3t7f9+fn5/4ODg/8AAAD/tbW1//////+hoaH+AAAA/3l5ef739/f/4ODg/gAAAP4KCgr/AAAA/gAAAP8AAAD/tbW1/vz8/P+4uLj/AAAA/319ff/l5eX/ZmZm/wAAAP8DAwP/CwsL/wAAAP/o6Oj+s7Oz/QAAAP8wMDD/AAAA/5SUlP7Z2dn+cXFx/wAAAP/Y2Nj//////9TU1P8AAAD/cHBw/+vr6//R0dH+RkZG/gAAAP8cHBz/AAAA/3Jycv7i4uL+cXFx/wAAAP8DAwP/DAwM/wAAAP/h4eH+///////////////////////////+/f3+5M+n/s6iF//Rpxn/5tOw/vXu4/7w5NH+6Na2/vTt4f///////////////////////Pz8/7u7u/xlZWX9AAAA/1hYWP6Xl5f8np6e/Zubm/2fn5/9np6e/c/Pz/v/////7Ozs/qampv5/f3/+fn5+/oaGhv7Ozs79+fn5/4ODg/8AAAD/srKy///////j4+P+oaGh/JSUlPzr6+v96urq/p6env6Hh4f+fX19/oSEhP6zs7P98/Pz//////+3t7f/AAAA/3p6ev/u7u7+paWl/Tc3N/4AAAD/eHh4/Zqamvzu7u7+0dHR/JWVlfzLy8v8ysrK/sLCwv7p6en+rq6u/ZKSkvzn5+f+/////+Xl5f6QkJD8rq6u/fDw8P/9/f3/wsLC/YmJif58fHz+goKC/qysrP7s7Oz+qqqq/To6Ov4AAAD/dnZ2/piYmPzo6Oj9///////////7+PT/9Ovd/vLo2P7jzaL+0KUe/9ClDv/RqDX/0KQq/9ClAP/OoQD/zJoA/9y/h/769/H///////////////////////////7AwMD8AAAA/4yMjP7u7u79/////v////7j4+P+2dnZ/uvr6/7////////////////+/v7+/f39/v////7/////+fn5/4ODg/8AAAD/srKy//////////////////////7////////////////////+/f39/v////7///////////////+3t7f/AAAA/3R0dP/9/f3/7+/v/nh4eP4AAAD/y8vL/P////7//////////v////7///////////////////////////////7////////////////////+/////v////////////////////79/f3+/////v////7/////8fHx/X9/f/0AAAD/xsbG/v////7///////////37+f/jzaX+zp8A/s6fAP/QpCH/2Ldt/93Chv/gxpH/38WP/9y/gf/XtGP/0KUU/9GmHv/v5ND+///////////////////////////Jycn+AAAA/0RERP+QkJD+0dHR/vz8/P9tbW3+AAAA/6ampv3/////////////////////////////////////+fn5/3t7e/8AAAD/r6+v//////////////////////////////////////////////////////////////////////+zs7P/AAAA/21tbf/6+vr/9fX1/re3t/5+fn7+19fX/f//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////9fX1/ru7u/2AgID+1dXV/v7+/v////////////v48//ZuHD+zZ0A/9WwUP/hyZj/5M2i/9/Ejv/bu3r/27x9/9/GlP/kzqL/38WP/9GnJf/Zt27/7uLM/vr38f7////////////////s7Oz+jo6O/ikpKf8AAAD/np6e/vn5+f6CgoL+Ojo6/6+vr/3/////////////////////////////////////+vr6/52dnf4+Pj7+s7Oz///////////////////////////////////////////////////////////////////////FxcX+U1NT/nx8fP/4+Pj///////7+/v729vb++fn5/v////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////7+/v/29vb++fn5/v////////////////n17v7UrEP+1KxJ/+POof/ew47/0aYW/82eAP/PogD/z6IA/8+hAP/TrED/4cmc/+HJmf/QpRr/z6MA/93Bh/769vD+////////////////8PDw/9jY2P7T09P+5ubm/v39/f/k5OT/29vb/+zs7P7//////////////////////////////////////v7+/+3t7f/d3d3/6+vr///////////////////////////////////////////////////////////////////////09PT/4ODg/uLi4v/9/f3/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+/n1/uPMof7QpSD/4MeT/9/Fkf/PogD/0agj/9WwU//SqBn/0KUA/86hAP/PogD/0ack/+LLnv/cwIP/z6MA/86hAP717uH+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8+vb+38WR/s+iAP/Ws2L/482h/9SsPv/NngD/38WQ//Dm0//UrUb/1K5I/97Civ/Urkr/zJwA/9azZf/iy5z/06tL/9ayWv77+PP////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////38un+0KYA/s+kAP/bvXn/4ciX/8+jAP/NnQD/69zD//Lo1//RpkH/69zC//n06//jzKH/5c6n/9q6dP/hyJf/1rJl/9u7ef79/Pr////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+/fz/3sSO/tCjCP/cwIL/3sOO/82eAP/bvHn/+fXu/+jXuP/RqDr/+PLp/+PNo//XtHD/7d/G/9q6df/fxZL/2bhs/9KoF/717eD+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////9e7i/tGoC/7cvn3/38WR/8uaAP/jzaP//fv4//Ts3//s3sX//fv5/97Div/PogD/0acZ/9ClAP/iypr/2bhs/86gAP/dwYf+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+PXu/tKqLv7ZuG3/4suc/82dAP/dwYz/+PTs/+HIl//t4Mn//Pn1/+jVs//QpAD/0KQA/9OsQP/jzJ7/17Ni/82fAP/ZuXD+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8OTR/s6gAP/Ur1P/482f/9ezY//SqTb/6tq+/+XQqf/dwIT/4sqb/9CkAP/RpwD/z6EA/9y/hP/hyJX/0acn/9i3av/z6tz+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////7eDI/s2eAP/OoAD/2719/+TOo//Tqz3/zJwA/9CkAP/PowD/z6IA/9CkAP/PogD/17Vl/+TPpf/Xs2H/1a9M/vbv4/7/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+vfy/ufVtP7YtW3+0KQB/97Ci//kzqP/2rp4/9KpM//QpQD/0KUA/9OtRf/cwIX/5M+l/9u8eP/NnQD/4MeZ/v37+f/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////17+P+3cGH/s+hAP/au3f/4cqZ/+PMnf/iypv/4suc/+LMnv/gyJT/1rNh/82fAP/KlwD/5M+r/v38+v//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8OTR/s+jAP/OoAD/0ac4/9WvX//Yt2r/2bhr/9ayYf/Rpij/061D/tu9f/7fxZP+9e3i////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+vfx/9/Ejv7SqSv+271+/ty+hP7QpgD/zqEA/86gAP/cvoD+9/Hp/vv59f/8+vf///7+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////z59f759u/+/Pv4//38+v/y6Nn+2Lhs/dq7dfz38un+////////////////////////////////", + "Description": "BMP", + "Moment": "{{current_moment}}" + }, + { + "Quantity": 0, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883584623476737, + "ftChargeItemCaseData": "G0AbMygbYQEddjAADQAyAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAcoAAAAAAAAAAAAAAAIB4AAAAAAAAAAAAAACaEAAAAAAAAAAAAAAGLYgAAAAAAAAAAAAAAmTIAAAAAAAAAAAAAARBJAAAAAAAAAAAAAACgKYAAAAAAAAAAAAABMDSAAAAAAAAAAAAAARMEAAAAAAAAAAAAAAKRAQAAAAAAAAAAAAABKDkAAAAAAAAAAAAAAJOjADiACAACAAAAAABMsoB5wAwAAwAAAAAAQkQAYYAcAAMYAAAAYGAMAGAADAADGAAAAGA6sAD8h4xHwz5JjDz4B1AA/4+Y5+c+eYz8+AAAAGHMDMBjOHmMwOAAAABhjA2AYxhhjGBgAAAAYY+Zg+cYYYx8YAAAAGGDjYdjGGGMHGAAAABhgM3OcxjhnAxgwAAAYc+cxmccYfzsecAAAGGPiGfjHmH0/HiAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAARAAAAAAAAAAAAACIAEQAAAAAAAAAAAAAiABAEAAAAAAAAAAAAJ48RHAAAAAAAAAAAACIBEQIAAAAAAAAAAAAiAREBAAAAAAAAAAAAIgUREgAAAAAAAAAAACIZETIAAAAAAAAAAAAiERMjAAAAAAAAAAAAIRMREgAAAAAAAAAAAACEEAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAChshABtFARshECAgICAgICAgICAgICAgICAgICAgICAgTUYgICAgICAgICAgICAgICAgICAgICAgIAobIQAgICAgICAgICAgICAgICBQaWF6emEgRHVvbW8gMjAvQyAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgMjAxMDAgTWlsYW5vICAgICAgICAgICAgICAgICAgChtFASAgICAgICAgICAgICBET0NVTUVOVE8gQ09NTUVSQ0lBTEUgICAgICAgICAgICAgIAobIQAbRQEgICAgICAgICAgICBkaSB2ZW5kaXRhIG8gcHJlc3RhemlvbmUgICAgICAgICAgICAKGyEAChtFAURFU0NSSVpJT05FICAgICAgICAgICAgICAgICAgIElWQSAgICAgIFByZXp6byjVKQobIQBGb29kL0JldmVyYWdlIC0gSXRlbSBWQVQgMTAlICAgICAgIDEwJSAgICAgICAgMTAKNywwMApGb29kL0JldmVyYWdlIC0gSXRlbSBWQVQgMTAlICAgICAgIDEwJSAgICAgICAgMTAKNywwMAoKG0UBGyEQVE9UQUxFIENPTVBMRVNTSVZPICAgICAgICAgICAgICAgICAgICAgICAgMjE0LDAwChshABtFARshEGRpIGN1aSBJVkEgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAxOSw0NQobIQAKUGFnYW1lbnRvIGNvbnRhbnRlICAgICAgICAgICAgICAgICAgICAgICAgMjE0LDAwCkltcG9ydG8gcGFnYXRvICAgICAgICAgICAgICAgICAgICAgICAgICAgIDIxNCwwMAoKICAgICAgICAgICAgICAgMzEtMTItMjAyNCAxMjo0NQ0gICAgICAgICAgICAgICAgCiAgICAgICAgICAgIERPQ1VNRU5UTyBOLiAwMDE0LTAwMDENICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgIENhc3NhIEZNIFRlc3QNICAgICAgICAgICAgICAgICAKCgoKCh1WABshAA==", + "Description": "Raster", + "Moment": "{{current_moment}}" + }, + { + "Quantity": 0, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883490134196225, + "ProductBarcode": "https://docs.fiskaltrust.cloud/docs/poscreators/middleware-doc/italy/reference-tables/ftreceiptcase", + "Description": "Link", + "Moment": "{{current_moment}}" + }, + { + "Quantity": 0, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883511609032705, + "ProductBarcode": "0123456789ABCDabcd", + "Description": "CUSTOMTYPE78", + "Moment": "{{current_moment}}" + } + ], + "cbPayItems": [], + "ftReceiptCase": 5283883447184535552 +} +"""; + return JsonConvert.DeserializeObject(receipt); + } + public static ReceiptRequest NonFiscal3() + { + var current_moment = DateTime.UtcNow; + var receipt = $$""" +{ + "ftCashBoxID": "00000000-0000-0000-0000-000000000000", + "ftPosSystemId": "00000000-0000-0000-0000-000000000000", + "cbTerminalID": "00010001", + "cbReceiptReference": "0001-0006", + "cbUser": "user1234", + "cbReceiptMoment": "{{current_moment}}", + "cbChargeItems": [ + { + "Quantity": 0, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883515904000001, + "ftChargeItemCaseData": "VEhJUyBJUyBBIFRFU1QgSU1BR0UNCk1BREUgQlkgVEVYVA==", + "Description": "BMP", + "Moment": "{{current_moment}}" + }, + { + "Quantity": 0, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883584623476737, + "ftChargeItemCaseData": "G0AbMygbYQEddjAADQAyAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAcoAAAAAAAAAAAAAAAIB4AAAAAAAAAAAAAACaEAAAAAAAAAAAAAAGLYgAAAAAAAAAAAAAAmTIAAAAAAAAAAAAAARBJAAAAAAAAAAAAAACgKYAAAAAAAAAAAAABMDSAAAAAAAAAAAAAARMEAAAAAAAAAAAAAAKRAQAAAAAAAAAAAAABKDkAAAAAAAAAAAAAAJOjADiACAACAAAAAABMsoB5wAwAAwAAAAAAQkQAYYAcAAMYAAAAYGAMAGAADAADGAAAAGA6sAD8h4xHwz5JjDz4B1AA/4+Y5+c+eYz8+AAAAGHMDMBjOHmMwOAAAABhjA2AYxhhjGBgAAAAYY+Zg+cYYYx8YAAAAGGDjYdjGGGMHGAAAABhgM3OcxjhnAxgwAAAYc+cxmccYfzsecAAAGGPiGfjHmH0/HiAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAARAAAAAAAAAAAAACIAEQAAAAAAAAAAAAAiABAEAAAAAAAAAAAAJ48RHAAAAAAAAAAAACIBEQIAAAAAAAAAAAAiAREBAAAAAAAAAAAAIgUREgAAAAAAAAAAACIZETIAAAAAAAAAAAAiERMjAAAAAAAAAAAAIRMREgAAAAAAAAAAAACEEAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAChshABtFARshECAgICAgICAgICAgICAgICAgICAgICAgTUYgICAgICAgICAgICAgICAgICAgICAgIAobIQAgICAgICAgICAgICAgICBQaWF6emEgRHVvbW8gMjAvQyAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgMjAxMDAgTWlsYW5vICAgICAgICAgICAgICAgICAgChtFASAgICAgICAgICAgICBET0NVTUVOVE8gQ09NTUVSQ0lBTEUgICAgICAgICAgICAgIAobIQAbRQEgICAgICAgICAgICBkaSB2ZW5kaXRhIG8gcHJlc3RhemlvbmUgICAgICAgICAgICAKGyEAChtFAURFU0NSSVpJT05FICAgICAgICAgICAgICAgICAgIElWQSAgICAgIFByZXp6byjVKQobIQBGb29kL0JldmVyYWdlIC0gSXRlbSBWQVQgMTAlICAgICAgIDEwJSAgICAgICAgMTAKNywwMApGb29kL0JldmVyYWdlIC0gSXRlbSBWQVQgMTAlICAgICAgIDEwJSAgICAgICAgMTAKNywwMAoKG0UBGyEQVE9UQUxFIENPTVBMRVNTSVZPICAgICAgICAgICAgICAgICAgICAgICAgMjE0LDAwChshABtFARshEGRpIGN1aSBJVkEgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAxOSw0NQobIQAKUGFnYW1lbnRvIGNvbnRhbnRlICAgICAgICAgICAgICAgICAgICAgICAgMjE0LDAwCkltcG9ydG8gcGFnYXRvICAgICAgICAgICAgICAgICAgICAgICAgICAgIDIxNCwwMAoKICAgICAgICAgICAgICAgMzEtMTItMjAyNCAxMjo0NQ0gICAgICAgICAgICAgICAgCiAgICAgICAgICAgIERPQ1VNRU5UTyBOLiAwMDE0LTAwMDENICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgIENhc3NhIEZNIFRlc3QNICAgICAgICAgICAgICAgICAKCgoKCh1WABshAA==", + "Description": "Raster", + "Moment": "{{current_moment}}" + }, + { + "Quantity": 0, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883490134196225, + "ProductBarcode": "https://docs.fiskaltrust.cloud/docs/poscreators/middleware-doc/italy/reference-tables/ftreceiptcase", + "Description": "Link", + "Moment": "{{current_moment}}" + }, + { + "Quantity": 0, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883511609032705, + "ProductBarcode": "0123456789ABCDabcd", + "Description": "CUSTOMTYPE78", + "Moment": "{{current_moment}}" + } + ], + "cbPayItems": [], + "ftReceiptCase": 5283883447184535552 +} +"""; + return JsonConvert.DeserializeObject(receipt); + } + public static ReceiptRequest NonFiscalReceipt() + { + var current_moment = DateTime.UtcNow; + var receipt = $$""" +{ + "ftCashBoxID": "00000000-0000-0000-0000-000000000000", + "ftPosSystemId": "00000000-0000-0000-0000-000000000000", + "cbTerminalID": "00010001", + "cbReceiptReference": "0001-0006", + "cbUser": "user1234", + "cbReceiptMoment": "{{current_moment}}", + "cbChargeItems": [ + { + "Quantity": 1, + "Amount": 107, + "VATRate": 10, + "ftChargeItemCase": 5283883447184523265, + "Description": "Food/Beverage - Item VAT 10%", + "Moment": "{{current_moment}}" + } + ], + "cbPayItems": [ + { + "Quantity": 1, + "Description": "Voucher", + "ftPayItemCase": 5283883447184523270, + "Moment": "{{current_moment}}", + "Amount": 10 + }, + { + "Quantity": 1, + "Description": "Cash", + "ftPayItemCase": 5283883447184523265, + "Moment": "{{current_moment}}", + "Amount": 97 + } + ], + "ftReceiptCase": 5283883447184535552 +} """; return JsonConvert.DeserializeObject(receipt); } diff --git a/scu-it/test/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter.UnitTest/ScuBootstrapperTests.cs b/scu-it/test/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter.UnitTest/ScuBootstrapperTests.cs index b30dd3893..c20207a89 100644 --- a/scu-it/test/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter.UnitTest/ScuBootstrapperTests.cs +++ b/scu-it/test/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter.UnitTest/ScuBootstrapperTests.cs @@ -1,5 +1,8 @@ using System; using System.Collections.Generic; +using System.Net.Http; +using System.Reflection.Metadata; +using System.Text; using fiskaltrust.ifPOS.v1.it; using Microsoft.Extensions.DependencyInjection; @@ -25,5 +28,35 @@ public void Test1() _ = serviceCollection.BuildServiceProvider().GetRequiredService(); } + [Fact] + public void Test2() + { + var content = EpsonRTPrinterSCU.PerformUnspecifiedProtocolReceipt(ReceiptExamples.NonFiscal()); + var data = fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter.Utilities.SoapSerializer.Serialize(content); + var httpClient = new HttpClient + { + BaseAddress = new Uri("http://10.0.0.40"), + Timeout = TimeSpan.FromMilliseconds(15000) + }; + var commandUrl = $"cgi-bin/fpmate.cgi?timeout=15000"; + var response = httpClient.PostAsync(commandUrl, new StringContent(data, Encoding.UTF8, "application/xml")).GetAwaiter().GetResult(); + + Console.WriteLine(response.Content.ReadAsStringAsync().GetAwaiter().GetResult()); + } + [Fact] + public void Test3() + { + var content = EpsonRTPrinterSCU.PerformUnspecifiedProtocolReceipt(ReceiptExamples.NonFiscalReceipt()); + var data = fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter.Utilities.SoapSerializer.Serialize(content); + var httpClient = new HttpClient + { + BaseAddress = new Uri("http://10.0.0.40"), + Timeout = TimeSpan.FromMilliseconds(15000) + }; + var commandUrl = $"cgi-bin/fpmate.cgi?timeout=15000"; + var response = httpClient.PostAsync(commandUrl, new StringContent(data, Encoding.UTF8, "application/xml")).GetAwaiter().GetResult(); + + Console.WriteLine(response.Content.ReadAsStringAsync().GetAwaiter().GetResult()); + } } } \ No newline at end of file diff --git a/scu-it/test/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter.UnitTest/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter.UnitTest.csproj b/scu-it/test/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter.UnitTest/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter.UnitTest.csproj index 089ac9854..e30d95ba7 100644 --- a/scu-it/test/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter.UnitTest/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter.UnitTest.csproj +++ b/scu-it/test/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter.UnitTest/fiskaltrust.Middleware.SCU.IT.EpsonRTPrinter.UnitTest.csproj @@ -12,8 +12,8 @@ - + + \ No newline at end of file