Beispiel #1
0
        public static void ReprintFChk(Guid CheckId)
        {
            try
            {
                FRSSrv.RemoteDataClient FClient = GetFRSClient();
                if (FClient != null)
                {
                    FRSSrv.AddCheckResponce Resp = FClient.PrintCheck(CheckId);

                    if (Resp.Check.Sucсess)
                    {
                        Utils.ToCardLog("ReprintFChk ExtNum " + Resp.Check.ExtNum + " ReprintFChk");
                        //  if (iniFile.FRSPrintCheck)
                        {
                            PrintOnWinPrinter.PrintDoc2(new PrintDocArgs()
                            {
                                FStrs = FiscalCheckCreator.GetFisckalCheckVisual(Resp), QRAsStr = Resp.Check.FROutData.QRAsStr
                            });
                        }
                    }
                    try
                    {
                        if (Resp.ParentCheck != null)
                        {
                            if (Resp.ParentCheck.Sucсess)
                            {
                                Utils.ToCardLog("ReprintFChk Parent ExtNum " + Resp.Check.ExtNum + " ReprintFChk");
                                //  if (iniFile.FRSPrintCheck)
                                {
                                    PrintOnWinPrinter.PrintDoc2(new PrintDocArgs()
                                    {
                                        FStrs = FiscalCheckCreator.GetFisckalCheckVisual(Resp, true), QRAsStr = Resp.ParentCheck.FROutData.QRAsStr
                                    });
                                }
                            }
                        }
                    }
                    catch (Exception ee)
                    {
                        Utils.ToCardLog("Error SendChk ParentCheck" + ee.Message);
                    }
                    FClient.Close();
                }
            }
            catch (Exception e)
            {
                Utils.ToCardLog("Error SendChk " + e.Message);
            }
        }
Beispiel #2
0
        private static List <FiscalCheckVisualString> GetCommonPaymentsStrings(FRSSrv.AddCheckResponce CheckParametrs, int t)
        {
            FRSSrv.FiskalCheck FCh = CheckParametrs.Check;

            List <FiscalCheckVisualString> strs = new List <FiscalCheckVisualString>();

            if (FCh.Payments == null || FCh.Payments.Count() == 0)
            {
                return(strs);
            }
            if (FCh.Payments.Any(a => a.ExternalId == 1))
            {
                strs.Add(new FiscalCheckVisualString(" НАЛИЧНЫМИ", "≡" + FCh.Payments.Where(a => a.ExternalId == 1).Sum(a => a.Summ).ToString("0.00").Replace(",", ".")));
            }
            if (FCh.Payments.Any(a => a.ExternalId != 1))
            {
                strs.Add(new FiscalCheckVisualString(" БЕЗНАЛИЧНЫМИ", "≡" + FCh.Payments.Where(a => a.ExternalId != 1).Sum(a => a.Summ).ToString("0.00").Replace(",", ".")));
            }


            return(strs);
        }
Beispiel #3
0
        private static List <FiscalCheckVisualString> GetPaymentsStrings(FRSSrv.AddCheckResponce CheckParametrs, int t)
        {
            FRSSrv.FiskalCheck FCh = CheckParametrs.Check;

            List <FiscalCheckVisualString> strs = new List <FiscalCheckVisualString>();

            foreach (FRSSrv.FiskalPayment Fpp in FCh.Payments)
            {
                if (Fpp.Summ == 0)
                {
                    continue;
                }
                if (t == 0)
                {
                    strs.Add(new FiscalCheckVisualString(" " + OldFRAttributes.PaymentNames[Fpp.Id], "≡" + Math.Min(Fpp.Summ, CheckParametrs.Check.FROutData.FNSumm).ToString("0.00").Replace(",", ".")));
                }
                else
                {
                    strs.Add(new FiscalCheckVisualString(" " + OldFRAttributes.PaymentNames[Fpp.Id], "≡" + Fpp.Summ.ToString("0.00").Replace(",", ".")));
                }
            }

            return(strs);
        }
Beispiel #4
0
        public static List <FiscalCheckVisualString> GetFisckalCheckVisual(FRSSrv.AddCheckResponce CheckParametrs, bool SecondChk = false)
        {
            Utils.ToCardLog("GetFisckalCheckVisual ExtNum: " + CheckParametrs.Check.ExtNum);
            // QrImg = null;
            try
            {
                FRSSrv.FiskalCheck FCh = CheckParametrs.Check;

                /*
                 * if (SecondChk)
                 * {
                 *  FCh = CheckParametrs.ParentCheck;
                 * }
                 * */
                List <FiscalCheckVisualString> strs = new List <FiscalCheckVisualString>();
                if (CheckParametrs != null)
                {
                    if (CheckParametrs.Attrs != null)
                    {
                        OldFRAttributes = CheckParametrs.Attrs;
                    }
                    foreach (string s in OldFRAttributes.Klishe)
                    {
                        strs.Add(new FiscalCheckVisualString(s, ""));
                    }
                    strs.Add(new FiscalCheckVisualString("РН ККТ: " + OldFRAttributes.RN.ToString(), FCh.FROutData.SysDt.ToString("dd.MM.yy HH:mm")));
                    strs.Add(new FiscalCheckVisualString("ЗН ККТ: " + OldFRAttributes.ZN.ToString(), String.Format("СМЕНА:{0} ЧЕК:{1}", OldFRAttributes.Smena, FCh.FROutData.SmallNum)));
                    if (FCh.ReturnSale)
                    {
                        strs.Add(new FiscalCheckVisualString("КАССОВЫЙ ЧЕК/ВОЗВРАТ ПРИХОДА", ""));
                    }
                    else
                    {
                        strs.Add(new FiscalCheckVisualString("КАССОВЫЙ ЧЕК/ПРИХОД", ""));
                    }
                    strs.Add(new FiscalCheckVisualString(String.Format("ИНН: {0}", OldFRAttributes.INN), String.Format("ФН:{0} ", OldFRAttributes.FNNumber)));
                    strs.Add(new FiscalCheckVisualString(String.Format("Кассир:{0}", OldFRAttributes.Cassir), String.Format("#{0} ", FCh.FROutData.bigNum)));
                    strs.Add(new FiscalCheckVisualString(String.Format("Сайт ФНС:"), String.Format("www.nalog.ru")));
                    if (FCh.StringsForPrintBefore != null)
                    {
                        foreach (string s in FCh.StringsForPrintBefore)
                        {
                            strs.Add(new FiscalCheckVisualString(s, ""));
                        }
                    }

                    if (FCh.Dishes != null)
                    {
                        foreach (FRSSrv.FiskalDish Fd in FCh.Dishes)
                        {
                            strs.Add(new FiscalCheckVisualString(Fd.Name, ""));
                            strs.Add(new FiscalCheckVisualString("", String.Format("{0} X {1}", Fd.Count.ToString(), Fd.Price.ToString("0.00")).Replace(",", ".")));
                            strs.Add(new FiscalCheckVisualString("", String.Format("≡{0}_A", (Fd.Count * Fd.Price).ToString("0.00")).Replace(",", ".")));
                        }
                    }
                    if (FCh.Discounts != null)
                    {
                        foreach (FRSSrv.FiskalDiscount fffd in FCh.Discounts)
                        {
                            strs.Add(new FiscalCheckVisualString(fffd.Name, fffd.Summ.ToString("0.00").Replace(",", ".")));
                        }
                    }
                    if (FCh.StringsForPrintAfter != null)
                    {
                        foreach (string s in FCh.StringsForPrintAfter)
                        {
                            strs.Add(new FiscalCheckVisualString(s, ""));
                        }
                    }
                    strs.Add(new FiscalCheckVisualString("ИТОГ:", String.Format("≡{0}", FCh.FROutData.FNSumm.ToString("0.00")).Replace(",", "."), true));
                    strs.AddRange(GetCommonPaymentsStrings(CheckParametrs, 0));
                    strs.Add(new FiscalCheckVisualString("ПОЛУЧЕНО:", ""));
                    strs.AddRange(GetPaymentsStrings(CheckParametrs, 1));
                    if (FCh.FROutData.Change > 0)
                    {
                        strs.Add(new FiscalCheckVisualString("СДАЧА:", String.Format("≡{0}", FCh.FROutData.Change.ToString("0.00")).Replace(",", ".")));
                    }

                    /*
                     * if (iniFile.FRNoTax)
                     * {
                     *  strs.Add(new FiscalCheckVisualString("Г: СУММА БЕЗ НАЛОГА", String.Format("≡{0}", FCh.FROutData.FNSumm.ToString("0.00")).Replace(",", ".")));
                     * }
                     * else
                     * {
                     *  strs.Add(new FiscalCheckVisualString("А: СУММА НДС 18%", String.Format("≡{0}", (FCh.FROutData.FNSumm * 0.152548m).ToString("0.00")).Replace(",", ".")));
                     * }
                     */

                    decimal nal = (OldFRAttributes.TaxPercent / 10000) / (1 + OldFRAttributes.TaxPercent / 10000);
                    if (OldFRAttributes.TaxPercent == 0)
                    {
                        nal = 1;
                    }
                    strs.Add(new FiscalCheckVisualString(OldFRAttributes.TaxName, String.Format("≡{0}", (FCh.FROutData.FNSumm * nal).ToString("0.00")).Replace(",", ".")));

                    strs.Add(new FiscalCheckVisualString("СНО: " + OldFRAttributes.TaxSystem, String.Format("ФД: {0} ФП: {1}", FCh.FROutData.FD, FCh.FROutData.FP)));
                    // QrImg = CreateQRBitmap(FCh.FROutData.QRAsStr, 130, 130);
                }

                return(strs);
            }
            catch (Exception e)
            {
                Utils.ToCardLog("GetFisckalCheckVisual error  ExtNum: " + CheckParametrs.Check.ExtNum + " " + e.Message);
            }
            return(null);
        }
        private static void StartFRSQueue()
        {
            //FRSClient.Init();
            Utils.ToCardLog("StartFRSQueue ");
            DirectoryInfo Di     = new DirectoryInfo(PDiscountCard.CloseCheck.ChecksPath);
            DirectoryInfo DiBugs = new DirectoryInfo(PDiscountCard.CloseCheck.ChecksPath + @"\bugs");

            if (!Di.Exists)
            {
                Di.Create();
            }
            List <DateTime> ZReps = new List <DateTime>();

            while (!mExitFRSThread)
            {
                Thread.Sleep(5000);
                ZReps.Clear();
                foreach (FileInfo fi in Di.GetFiles("*.zrep"))
                {
                    try
                    {
                        int      d  = Convert.ToInt32(fi.Name.Substring(4, 2));
                        int      m  = Convert.ToInt32(fi.Name.Substring(6, 2));
                        int      y  = Convert.ToInt32(fi.Name.Substring(8, 4));
                        DateTime bd = new DateTime(y, m, d);
                        Utils.ToCardLog("Find ZRepFile " + bd.ToString());
                        if (ZReps.Contains(bd))
                        {
                            continue;
                        }
                        if (TmpChecksWithBDExist(bd))
                        {
                            Utils.ToCardLog("Find ZRepFile checks exist");
                            continue;
                        }
                        fi.Delete();
                        ZReps.Add(bd);
                        FRSClient.ZReport(bd);
                    }
                    catch (Exception e)
                    {
                        Utils.ToCardLog("Error find ZRepFile " + e.Message);
                    }
                }

                foreach (FileInfo fi in Di.GetFiles("*.5").OrderBy(a => a.CreationTime))
                {
                    try
                    {
                        Utils.ToCardLog("FRSQueue Read file " + fi.FullName);
                        Check Ch = PDiscountCard.CloseCheck.ReadCheckFromTmp(fi.FullName);
                        if (Ch == null)
                        {
                            //Di
                            if (!DiBugs.Exists)
                            {
                                DiBugs.Create();
                            }
                            fi.MoveTo(DiBugs.FullName + @"\" + fi.Name);
                            continue;
                        }
                        Utils.ToCardLog("FRSQueue send");
                        FRSSrv.AddCheckResponce res = FRSClient.SendAlohaChk(Ch);
                        if (res == null)
                        {
                            break;
                        }
                        if (res.Check.NeedUpdateItems)
                        {
                            Utils.ToCardLog("NeedUpdateItems");

                            FRSClient.UpdateItems();
                        }

                        if ((res.ChkAlreadyExistInSQL) && (res.Check != null) && (res.Check.Sucсess))
                        {
                        }

                        if (res.SQLAddErrorException != null && res.SQLAddErrorException != "")
                        {
                            Utils.ToCardLog("StartFRSQueue res.SQLAddErrorException: " + res.SQLAddErrorException);
                            continue;
                        }
                        fi.Delete();
                        res = null;
                        Utils.ToCardLog("FRSQueue file complited " + fi.FullName);
                    }
                    catch (Exception e)
                    {
                        Utils.ToCardLog("Error StartFRSQueue " + e.Message);
                        break;
                    }
                }
            }
        }