public static void SendTestChk() { FiskalDish fd = new FiskalDish() { Count = 1.32m, Name = "Тест блюдо 1", Price = 25.35m }; FiskalDish fd2 = new FiskalDish() { Count = 10m, Name = "Тест блюдо 2", Price = 20m }; List <FiskalDish> Fdd = new List <FiskalDish>(); Fdd.Add(fd); Fdd.Add(fd2); for (int i = 0; i < 25; i++) { FiskalDish fd3 = new FiskalDish() { Count = 1m, Name = "Тест блюдо 2", Price = 20m }; Fdd.Add(fd3); } FiskalCheck FCh = new FiskalCheck(); FCh.BusinessDate = AlohainiFile.BDate; FCh.SystemDate = DateTime.Now; FCh.Id = Guid.NewGuid(); FCh.Dishes = Fdd.ToArray(); FCh.Dep = AlohainiFile.DepNum; FCh.Term = 0; Random R = new Random(); FCh.ExtNumData = R.Next(4000000).ToString(); FCh.ExtNum = R.Next(4000000); /* * FiskalPayment Fp = new FiskalPayment() * { * Id = 1, * Summ = 1000 * }; * */ FiskalPayment Fp2 = new FiskalPayment() { Id = 1, Summ = 223.46m + 1000m }; FiskalPayment Fp3 = new FiskalPayment() { Id = 4, Summ = 10m }; List <FiskalPayment> Fpp = new List <FiskalPayment>(); Fpp.Add(Fp2); Fpp.Add(Fp3); FCh.Payments = Fpp.ToArray(); SendChk(FCh); }
private static FRSSrv.FiskalCheck GetFiskalCheckFromAlohaChk(Check Chk) { FRSSrv.FiskalCheck Tmp = new FiskalCheck() { Id = Guid.NewGuid(), BusinessDate = Chk.BusinessDate, SystemDate = Chk.SystemDate, Dep = AlohainiFile.DepNum, Term = AlohaTSClass.GetTermNum(), ExtNum = Chk.AlohaCheckNum, ExtNumData = Chk.CheckShortNum.ToString(), ReturnSale = Chk.Vozvr, TableNum = Chk.TableNumber, Waiter = Chk.Waiter, Cassir = Chk.Cassir }; List <FRSSrv.FiskalDish> Fdd = new List <FRSSrv.FiskalDish>(); //foreach (Dish D in Chk.Dishez) foreach (Dish D in Chk.ConSolidateDishez) //foreach (Dish D in Chk.ConSolidateSpoolDishez) { if (D.BarCode == 999901) { continue; } FRSSrv.FiskalDish Fd = new FiskalDish() { Count = (decimal)(D.QUANTITY * D.Count), Name = D.CHITNAME + " " + D.CardPrefix + D.CardNumber, Price = Math.Round(Math.Abs((decimal)D.Price) + Math.Abs((decimal)D.ServiceChargeSumm) / ((decimal)(D.QUANTITY * D.Count)), 2), Barcode = D.BarCode }; if (iniFile.FRNoTax) { Fd.Tax = 0; } else { Fd.Tax = 1; } Fdd.Add(Fd); } Tmp.Dishes = Fdd.ToArray(); List <FRSSrv.FiskalPayment> Fpp = new List <FRSSrv.FiskalPayment>(); FRSSrv.FiskalPayment Fp1 = new FiskalPayment() { Id = 1, Summ = Chk.CashSummWithOverpayment2 }; foreach (AlohaTender tdr in Chk.Tenders) { if (tdr.AlohaTenderId == 1) { Fpp.Add(new FiskalPayment() { Id = 1, Summ = (decimal)Math.Abs(tdr.SummWithOverpayment), ExternalId = tdr.AlohaTenderId }); } else if (tdr.AlohaTenderId == 20) { Fpp.Add(new FiskalPayment() { Id = 4, Summ = (decimal)Math.Abs(tdr.Summ), ExternalId = tdr.AlohaTenderId }); } else if (AlohaTender.AlohaBallsTenderIds.Contains(tdr.AlohaTenderId)) //25,26 { if (tdr.AuthId == 2) { Fpp.Add(new FiskalPayment() { Id = 2, Summ = (decimal)Math.Abs(tdr.Summ), ExternalId = tdr.AlohaTenderId }); } } else { Fpp.Add(new FiskalPayment() { Id = 0, Summ = (decimal)Math.Abs(tdr.Summ), ExternalId = tdr.AlohaTenderId }); } } /* * foreach (AlohaTender P in Chk.Tenders) * { * FRSSrv.FiskalPayment Fp = new FiskalPayment() { * Id = P.AlohaTenderId, * Summ = (decimal)P.SummWithOverpayment * }; * Fpp.Add(Fp); * } * */ Tmp.Payments = Fpp.ToArray(); List <FRSSrv.FiskalDiscount> FDiscs = new List <FRSSrv.FiskalDiscount>(); if (Math.Abs(Chk.Comp) > 0) { FRSSrv.FiskalDiscount Fds = new FiskalDiscount() { Discount = true, }; Fds.Name = "Комплексная скидка"; if (Chk.CompId == AlohaTSClass.BonusCompId) { Fds.Name = "Оплата баллами"; } Fds.Summ = Chk.Comp; FDiscs.Add(Fds); } if (Chk.Dishez.Where(a => a.BarCode == 999901).Count() > 0) { Dish d = Chk.Dishez.Where(a => a.BarCode == 999901).First(); FRSSrv.FiskalDiscount Fds = new FiskalDiscount() { Discount = true, }; Fds.Name = "Скидка " + d.LongName; Fds.Summ = d.Price; //if (Chk.CompId == AlohaTSClass.BonusCompId) { Fds.Name = "Оплата баллами"; } ///Fds.Summ = Chk.Comp; FDiscs.Add(Fds); } Tmp.Discounts = FDiscs.ToArray(); Tmp.StringsForPrintBefore = Chk.FrStringsBefore.ToArray(); Tmp.StringsForPrintAfter = Chk.FrStringsAfter.ToArray(); if (Chk.Tenders.Count > 0) { decimal DishSumm = Math.Abs(Tmp.Dishes.Sum(a => a.Price * a.Count)); decimal PSumm = Math.Abs((decimal)Chk.Tenders.Sum(a => a.Summ)); try { if (Math.Abs(PSumm - DishSumm) >= 0.01m) { Utils.ToCardLog("GetFiskalCheckFromAlohaChk diff summ change " + (PSumm - DishSumm).ToString()); FiskalDish d = Tmp.Dishes.Where(a => Math.Abs(a.Price) > 0.01m && a.Count == Tmp.Dishes.Min(b => b.Count)).First(); Utils.ToCardLog("GetFiskalCheckFromAlohaChk diff summ change old Pr" + d.Price); d.Price = d.Price + (PSumm - DishSumm) / d.Count; Utils.ToCardLog("GetFiskalCheckFromAlohaChk diff summ change new Pr" + d.Price); } } catch (Exception e) { Utils.ToCardLog("Error GetFiskalCheckFromAlohaChk diff summ change " + e.Message); } } return(Tmp); }