示例#1
0
        private FiskalDrivers.FiskalCheck GetChk()
        {
            FiskalDrivers.FiskalCheck fc = new FiskalDrivers.FiskalCheck();
            FiskalDrivers.FiskalDish  fd = new FiskalDrivers.FiskalDish()
            {
                Name     = "Бл1",
                Price    = 12.34,
                Quantity = 1
            };
            fc.Dishes.Add(fd);
            FiskalDrivers.FiskalDish fd2 = new FiskalDrivers.FiskalDish()
            {
                Name     = "Бл2",
                Price    = 150,
                Quantity = 5
            };
            FiskalDrivers.FiskalDish fd3 = new FiskalDrivers.FiskalDish()
            {
                Name     = "Бл3",
                Price    = 750,
                Quantity = 0.25
            };

            fc.Dishes.Add(fd2);
            fc.Dishes.Add(fd3);
            fc.Summ = 1000;
            return(fc);
        }
示例#2
0
        static void CheckCloseQuere()
        {
            Utils.ToLog("CheckCloseQuere mCheckCloseThread=" + mCheckCloseThread);
            while (!mCheckCloseThread)
            {
                try
                {
                    OrderToAlohaSrv.Order Or = OrderToAlohaSrv.ToSql.GetNonCloseCheck();

                    if (!(Or == null))
                    {
                        Utils.ToLog("Get FCheck");
                        FiskalDrivers.FiskalCheck Fchk = GetFiskalCheckFromOrder(Or);

                        if ((Fchk.Payments.Where(a => a.PaymentType > 0).Count() == 0) || Fchk.Dishes.Count() == 0)
                        {
                            OrderToAlohaSrv.ToSql.UpdateCloseCheck(Or.StNum.Value);
                            continue;
                        }
                        bool res = FiskalDrivers.FiskalDriver.CloseCheck(Fchk);
                        if (res)
                        {
                            OrderToAlohaSrv.ToSql.UpdateCloseCheck(Or.StNum.Value);
                        }
                    }
                    Thread.Sleep(2000);
                }
                catch (Exception e)
                {
                    Utils.ToLog("Error CheckCloseQuere " + e.Message);
                }

                try
                {
                    OrderToAlohaSrv.Order Or = OrderToAlohaSrv.ToSql.GetNeedPrecheck();
                    //  Utils.ToLog("OrderToAlohaSrv.Order Or = OrderToAlohaSrv.ToSql.GetNonCloseCheck();");
                    if (!(Or == null))
                    {
                        Utils.ToLog("Get PreCheck");
                        FiskalDrivers.FiskalCheck Fchk = GetFiskalCheckFromOrder(Or);

                        bool res = FiskalDrivers.FiskalDriver.PrintPreCheck(Fchk);
                        if (res)
                        {
                            OrderToAlohaSrv.ToSql.UpdatePrintPreCheck(Or.StNum.Value);
                        }
                    }
                    Thread.Sleep(2000);
                }
                catch (Exception e)
                {
                    Utils.ToLog("Error CheckCloseQuere " + e.Message);
                }
            }
        }
示例#3
0
        static FiskalDrivers.FiskalCheck GetFiskalCheckFromOrder(OrderToAlohaSrv.Order ord)
        {
            FiskalDrivers.FiskalCheck Tmp = new FiskalDrivers.FiskalCheck();
            Tmp.CheckNum   = ord.StNum.ToString();
            Tmp.TimeofOpen = ord.TimeofShipping.Value;
            Tmp.Cassir     = ord.CompanyName;
            Tmp.Waiter     = ord.BortName;
            Tmp.FlyCheck   = true;
            foreach (OrderToAlohaSrv.OrderItem oi in ord.OrderItems.Where(a => !a.Deleted.Value && a.Price > 0 && !a.Alk))
            {
                FiskalDrivers.FiskalDish fd = new FiskalDrivers.FiskalDish()
                {
                    Name     = OrderToAlohaSrv.ToSql.SQLGetDishName(oi.Barcode.Value),
                    Price    = (double)oi.Price.Value,
                    Quantity = oi.Quantity.Value
                };
                Tmp.Dishes.Add(fd);
            }

            Tmp.Discount = (double)ord.ComplexDisc + (double)ord.StDiscount;
            if ((Tmp.Discount > 0) && (ord.Margin > 0))
            {
                if (Tmp.Discount > (double)ord.Margin)
                {
                    Tmp.Discount -= (double)ord.Margin;
                }
                else
                {
                    Tmp.Charge   = (double)ord.Margin - Tmp.Discount;
                    Tmp.Discount = 0;
                }
            }
            else if (ord.Margin > 0)
            {
                Tmp.Charge = (double)ord.Margin;
            }

            foreach (OrderToAlohaSrv.OrderPayment op in ord.OrderPayments)
            {
                //OrderToAlohaSrv.OrderPayment op = ord.OrderPayments;
                FiskalDrivers.FiskalPayment fp = new FiskalDrivers.FiskalPayment()
                {
                    Name        = op.TNDR.Name,
                    Summ        = (double)op.Summ.Value,
                    PaymentType = op.TNDR.FisckalId.Value,
                    //  NonFiskalPayment = op.TNDR.
                };
                Tmp.Payments.Add(fp);
            }
            Tmp.Summ = (double)(ord.Summ - ord.StDiscount - ord.ComplexDisc + ord.Margin);
            return(Tmp);
        }
示例#4
0
        static void CheckCloseQuere()
        {
            Utils.ToLog("CheckCloseQuere mCheckCloseThread=" + mCheckCloseThread);

            //DateTime sDt = DateTime.Now.AddMonths(-1);
            //DateTime eDt = DateTime.Now.AddMonths(1);
            while (!mCheckCloseThread)
            {
                try
                {
                    var q           = new DBQuery();
                    var ToFlyChecks = q.GetNonClosingCheck();

                    if (!(ToFlyChecks == null))
                    {
                        foreach (var ch in ToFlyChecks)
                        {
                            Utils.ToLog("Get FCheck");
                            FiskalDrivers.FiskalCheck Fchk = GetFiskalCheckFromOrder(ch);

                            if (Fchk.Dishes.Count() == 0)
                            {
                                if (!q.UpdateClosingCheck(ch, false, true))
                                {
                                    mCheckCloseThread = true;
                                }
                                continue;
                            }
                            if (ch.NeedPrintFR)
                            {
                                if (Fchk.Payments.Where(a => a.PaymentType > 0).Count() == 0)
                                {
                                    if (!q.UpdateClosingCheck(ch, true, false))
                                    {
                                        mCheckCloseThread = true;
                                    }
                                }
                                else
                                {
                                    if (!q.UpdateClosingCheck(ch, true, false))
                                    {
                                        mCheckCloseThread = true;
                                    }
                                    else
                                    {
                                        bool res = FiskalDrivers.FiskalDriver.CloseCheck(Fchk);
                                    }
                                }
                            }
                        }
                    }

                    var ToGoChecks = q.GetNonToGoClosingCheck();

                    if (!(ToGoChecks == null))
                    {
                        foreach (var ch in ToGoChecks)
                        {
                            Utils.ToLog("Get FCheckToGo");
                            FiskalDrivers.FiskalCheck Fchk = GetFiskalCheckFromOrder(ch);

                            if (Fchk.Dishes.Count() == 0)
                            {
                                Utils.ToLog("Fchk.Dishes.Count() == 0");
                                if (!q.UpdateClosingCheck(ch, false, true))
                                {
                                    mCheckCloseThread = true;
                                }
                                continue;
                            }
                            if (ch.NeedPrintFR)
                            {
                                Utils.ToLog("ch.NeedPrintFR");

                                /*
                                 * if (Fchk.Payments.Where(a => a.PaymentType > 0).Count() == 0)
                                 * {
                                 *  Utils.ToLog("Fchk.Payments.Where(a => a.PaymentType > 0).Count() == 0");
                                 *  if (!q.UpdateClosingCheck(ch, true, false))
                                 *  {
                                 *      mCheckCloseThread = true;
                                 *  }
                                 * }
                                 * else
                                 * */
                                {
                                    if (!q.UpdateClosingCheck(ch, true, false))
                                    {
                                        mCheckCloseThread = true;
                                    }
                                    else
                                    {
                                        Utils.ToLog("Print");
                                        bool res = FiskalDrivers.FiskalDriver.CloseCheck(Fchk);
                                    }
                                }
                            }
                        }

                        /*
                         * else if (Or.NeedPrintPrecheck)
                         * {
                         *  Utils.ToLog("NeedPrintPrecheck");
                         *  bool res = FiskalDrivers.FiskalDriver.PrintPreCheck(Fchk);
                         *  if (res)
                         *  {
                         *      if (!q.UpdateClosingCheck(Or, false, true))
                         *      {
                         *          mCheckCloseThread = true;
                         *      }
                         *  }
                         * }
                         * */
                    }
                    Thread.Sleep(2000);
                }
                catch (Exception e)
                {
                    Utils.ToLog("Error CheckCloseQuere " + e.Message);
                }

                /*
                 * try
                 * {
                 *  OrderToAlohaSrv.Order Or = OrderToAlohaSrv.ToSql.GetNeedPrecheck();
                 *  //  Utils.ToLog("OrderToAlohaSrv.Order Or = OrderToAlohaSrv.ToSql.GetNonCloseCheck();");
                 *  if (!(Or == null))
                 *  {
                 *      Utils.ToLog("Get PreCheck");
                 *      FiskalDrivers.FiskalCheck Fchk = GetFiskalCheckFromOrder(Or);
                 *
                 *      bool res = FiskalDrivers.FiskalDriver.PrintPreCheck(Fchk);
                 *      if (res)
                 *      {
                 *          OrderToAlohaSrv.ToSql.UpdatePrintPreCheck(Or.StNum.Value);
                 *      }
                 *  }
                 *  Thread.Sleep(2000);
                 * }
                 * catch (Exception e)
                 * {
                 *  Utils.ToLog("Error CheckCloseQuere " + e.Message);
                 * }
                 */
            }
        }
示例#5
0
        public static FiskalDrivers.FiskalCheck GetFiskalCheckFromOrder(OrderToGo ord)
        {
            FiskalDrivers.FiskalCheck Tmp = new FiskalDrivers.FiskalCheck();
            Tmp.CheckNum   = ord.Id.ToString();
            Tmp.TimeofOpen = ord.DeliveryDate;

            /*
             * Tmp.Cassir = ord.AirCompany.Name;
             * Tmp.Waiter = ord.FlightNumber;
             * */
            Tmp.FlyCheck = false;
            double tmpSumm = 0;

            foreach (var oi in ord.DishPackages.Where(a => a.TotalPrice > 0 && !a.Dish.IsAlcohol))
            {
                FiskalDrivers.FiskalDish fd = new FiskalDrivers.FiskalDish()
                {
                    Name     = oi.DishName,
                    Price    = (double)oi.TotalPrice * (1 - (double)ord.DiscountPercent / 100),
                    Quantity = (double)oi.Amount
                };
                tmpSumm += fd.Price * fd.Quantity;
                Tmp.Dishes.Add(fd);
            }

            if (ord.DiscountPercent > 0)
            {
                Tmp.Discount     = (double)(ord.DishPackages.Sum(a => a.TotalPrice * a.Amount) * (ord.DiscountPercent / 100));
                Tmp.DiscountName = "Скидка ";
            }
            var diff = tmpSumm - ((double)ord.DishPackages.Sum(a => a.TotalPrice * a.Amount) - Tmp.Discount);

            if (Math.Abs(diff) > 0.001)
            {
                if (Tmp.Dishes.Any(a => a.Price * a.Quantity > diff))
                {
                    var d = Tmp.Dishes.Where(a => a.Price * a.Quantity > diff).FirstOrDefault();
                    d.Price = d.Price - diff / d.Quantity;
                }
            }


            if (ord.DeliveryPrice > 0)
            {
                FiskalDrivers.FiskalDish fd = new FiskalDrivers.FiskalDish()
                {
                    Name     = "Доставка",
                    Price    = (double)ord.DeliveryPrice,
                    Quantity = 1
                };
                Tmp.Dishes.Add(fd);
            }

            // double DSumm = (double)ord.DishPackages.Sum(a => a.TotalPrice * a.Amount) + (double)ord.DeliveryPrice;
            double DSumm = (double)Tmp.Dishes.Sum(a => a.Price * a.Quantity);

            /*
             * double ExCh = 0;
             * Tmp.Discount =  0;
             * if ((Tmp.Discount > 0) && (ExCh > 0))
             * {
             *  if (Tmp.Discount > ExCh)
             *  {
             *      Tmp.Discount -= ExCh;
             *  }
             *  else
             *  {
             *
             *      Tmp.Charge = ExCh - Tmp.Discount;
             *      Tmp.Discount = 0;
             *  }
             * }
             * else if (ExCh > 0)
             * {
             *  Tmp.Charge = ExCh;
             * }
             */

            //double DSummTotal = DSumm - Tmp.Discount + Tmp.Charge;
            var op = ord.PaymentType;

            //OrderToAlohaSrv.OrderPayment op = ord.OrderPayments;
            FiskalDrivers.FiskalPayment fp = new FiskalDrivers.FiskalPayment()
            {
                Name        = op.Name,
                Summ        = DSumm,
                PaymentType = (int)op.FiskalId
                              //  NonFiskalPayment = op.TNDR.
            };
            Tmp.Payments.Add(fp);

            Tmp.Summ = DSumm;
            return(Tmp);
        }
示例#6
0
        public static FiskalDrivers.FiskalCheck GetFiskalCheckFromOrder(OrderFlight ord)
        {
            FiskalDrivers.FiskalCheck Tmp = new FiskalDrivers.FiskalCheck();
            Tmp.CheckNum   = ord.Id.ToString();
            Tmp.TimeofOpen = ord.DeliveryDate;
            Tmp.Cassir     = ord.AirCompany.Name;
            Tmp.Waiter     = ord.FlightNumber;
            Tmp.FlyCheck   = true;
            foreach (var oi in ord.DishPackages.Where(a => a.TotalPrice > 0 && !a.Dish.IsAlcohol))
            {
                FiskalDrivers.FiskalDish fd = new FiskalDrivers.FiskalDish()
                {
                    Name     = oi.DishName,
                    Price    = (double)oi.TotalPrice,
                    Quantity = (double)oi.Amount
                };
                Tmp.Dishes.Add(fd);
            }
            foreach (var oi in ord.DishPackages.Where(a => a.TotalPrice > 0 && a.Dish.IsAlcohol))
            {
                FiskalDrivers.FiskalDish fd = new FiskalDrivers.FiskalDish()
                {
                    Name     = "Открытый напиток",
                    Price    = (double)oi.TotalPrice,
                    Quantity = (double)oi.Amount
                };
                Tmp.Dishes.Add(fd);
            }
            double DSumm = (double)ord.DishPackages.Sum(a => a.TotalPrice * a.Amount);
            double ExCh  = DSumm * (double)ord.ExtraCharge / 100;

            Tmp.Discount = (double)ord.DiscountSumm;
            if ((Tmp.Discount > 0) && (ExCh > 0))
            {
                if (Tmp.Discount > ExCh)
                {
                    Tmp.Discount -= ExCh;
                }
                else
                {
                    Tmp.Charge   = ExCh - Tmp.Discount;
                    Tmp.Discount = 0;
                }
            }
            else if (ExCh > 0)
            {
                Tmp.Charge = ExCh;
            }

            double DSummTotal = DSumm - Tmp.Discount + Tmp.Charge;
            var    op         = ord.AirCompany.PaymentType;

            //OrderToAlohaSrv.OrderPayment op = ord.OrderPayments;
            FiskalDrivers.FiskalPayment fp = new FiskalDrivers.FiskalPayment()
            {
                Name        = op.Name,
                Summ        = DSummTotal,
                PaymentType = (int)op.FiskalId
                              //  NonFiskalPayment = op.TNDR.
            };
            if (fp.PaymentType == 0)
            {
                fp.Name = "Наличные";
            }
            Tmp.Payments.Add(fp);

            Tmp.Summ = DSummTotal;
            return(Tmp);
        }
示例#7
0
 private void button39_Click(object sender, EventArgs e)
 {
     FiskalDrivers.FiskalCheck Chk = GetChk();
     Chk.IsVoid = true;
     FiskalDrivers.FiskalDriver.CloseCheck(Chk);
 }