Ejemplo n.º 1
0
        private static FRSSrv.AddCheckResponce SendChk(FRSSrv.FiskalCheck Chk)
        {
            try
            {
                long Mbefore = GC.GetTotalMemory(false);
                Utils.ToCardLog("SendChk memory " + Mbefore);

                FRSSrv.AddCheckResponce Resp    = new AddCheckResponce();
                FRSSrv.RemoteDataClient FClient = GetFRSClient();
                if (FClient != null)
                {
                    FRSSrv.AddCheckRequest Request = new FRSSrv.AddCheckRequest()
                    {
                        Id    = new Guid(),
                        Check = Chk
                    };

                    Resp = FClient.AddCheck(Request);

                    if (Resp.Check.Sucсess)
                    {
                        Utils.ToCardLog("SendChk ExtNum " + Chk.ExtNum + " ClosedSucsees");

                        if ((iniFile.FRSPrintCheck) && (!Resp.Check.WrongChk))
                        {
                            PrintOnWinPrinter.PrintDoc2(new PrintDocArgs()
                            {
                                FStrs = FiscalCheckCreator.GetFisckalCheckVisual(Resp), QRAsStr = Resp.Check.FROutData.QRAsStr
                            });
                        }
                    }
                    FClient.InnerChannel.Close();
                    FClient.InnerChannel.Dispose();
                    FClient.Close();
                    long MAfter = GC.GetTotalMemory(false);
                    Utils.ToCardLog("SendChk memory " + MAfter);
                }
                return(Resp);
            }
            catch (Exception e)
            {
                Utils.ToCardLog("Error SendChk " + e.Message);
                return(null);
            }



            //System.Windows.Forms.MessageBox.Show(Resp.Check.FD+" "+Resp.Check.FP);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }