Beispiel #1
0
        static void PrintXML(string xml)
        {
            CheckPackage checkPackage = DeserializeXMLFileToObject <CheckPackage>(GenerateStreamFromString(xml));

            if (checkPackage == null)
            {
                FR.Start();
                if (xml.Trim().StartsWith("#PrintXReport"))
                {
                    FR.PrintXReport();
                    FR.Stop();
                    return;
                }
                else if (xml.Trim().StartsWith("#PrintZReport"))
                {
                    FR.PrintZReport();
                    FR.Stop();
                    return;
                }
                else
                {
                    //FR.PrintString("Error XML parse!");
                    FR.PrintString(xml);
                    FR.Feed(6);
                    FR.PartialCut();
                    FR.Stop();
                    return;
                }
            }
            else
            {
                //Log("checkPackage.Positions.Count = " + checkPackage.Positions.Count.ToString());
                ProcessCheck(checkPackage);
            }
        }
Beispiel #2
0
        static void ProcessCheck(CheckPackage checkPackage)
        {
            int Result;

            if (checkPackage.Positions.Items.Length == 0)
            {
                Log("Positions = 0");
                return;
            }

            Log("ProcessCheck");
            Log("Positions = " + checkPackage.Positions.Items.Length);

            FR.Start();

            Log("SetMode ");
            Result = FR.SetMode(1, "30");
            Log("Result = " + Result);

            if (Result == -3822)
            {
                FR.PrintString("Смена превысила 24 часа!");
                FR.PrintString("Для продолжения снимите Z-Отчет.");
                FR.Feed(6);
                FR.PartialCut();
                FR.Stop();
                return;
            }

            int CheckMode = 1;
            int CheckType = Convert.ToInt32(checkPackage.Parameters.PaymentType);

            Log("OpenCheck CheckMode=" + CheckMode + " CheckType=" + CheckType);
            Result = FR.OpenCheck(CheckMode, CheckType);
            Log("Result = " + Result);

            // Применяемая система налогооблажения в чеке:
            long TaxVariant = AtolGetTaxVariantByLong(checkPackage.Parameters.TaxVariant);

            FR.WriteAttribute(1055, TaxVariant.ToString());

            // Позиции чека
            for (int i = 0; i < checkPackage.Positions.Items.Length; i++)
            {
                if (checkPackage.Positions.ItemsElementName[i] == ItemsChoiceType.FiscalString)
                {
                    PrintFiscalString((FiscalString)checkPackage.Positions.Items[i]);
                }
                else if (checkPackage.Positions.ItemsElementName[i] == ItemsChoiceType.TextString)
                {
                    PrintTextString((TextString)checkPackage.Positions.Items[i]);
                }
                else if (checkPackage.Positions.ItemsElementName[i] == ItemsChoiceType.BarcodeString)
                {
                    PrintBarcodeString((BarcodeString)checkPackage.Positions.Items[i]);
                }
                else
                {
                    Log("Unknown position " + checkPackage.Positions.Items[i].ToString());
                }
            }

            // Оплата
            Log("Payment");
            double Cash          = checkPackage.Payments.Cash;
            double CashLessType1 = checkPackage.Payments.CashLessType1;
            double CashLessType2 = checkPackage.Payments.CashLessType2;
            double CashLessType3 = checkPackage.Payments.CashLessType3;

            Log("Cash = " + Cash.ToString() + " CashLessType1 = " + CashLessType1.ToString() + " CashLessType2 = " + CashLessType2.ToString() + " CashLessType3 = " + CashLessType3.ToString());

            double Remainder = 0;
            double Change    = 0;

            FR.Payment(Cash, 0, ref Remainder, ref Change);
            FR.Payment(CashLessType1, 1, ref Remainder, ref Change);
            FR.Payment(CashLessType2, 2, ref Remainder, ref Change);
            FR.Payment(CashLessType3, 3, ref Remainder, ref Change);

            Log("CloseCheck");
            Result = FR.CloseCheck();
            Log("Result = " + Result);

            string ResultDescription = FR.ResultDescription();

            if (Result != 0)
            {
                Log("Error: " + Result.ToString() + " - " + ResultDescription);
                FR.PrintString("Error: " + Result.ToString() + " - " + ResultDescription);
                Log("Abort");
                FR.Abort();
            }

            Log("Stop");
            FR.Stop();
        }
Beispiel #3
0
 static void PrintTextString(TextString ts)
 {
     FR.PrintString(ts.Text);
 }