Ejemplo n.º 1
0
        static async Task TestReceiptAsync()
        {
            //var TerminalId = Guid.Parse("1bb89aa9-dbdf-4eb0-b7a2-094665c3fdd0");//14
            var TerminalId =                                                     //Guid.Parse("c2211a23-b856-4dd4-ba29-3ec2d043efbf");
                                                                                 //Guid.Parse("27aaa6d3-8824-475d-a7d4-3269472ba950");//19
                             Guid.Parse("85db1663-6284-4b62-9481-7b7aad4fb3bc"); //17
            var ProductId = Guid.Parse("00000000-abcd-0000-0019-000000141231");
            var FastGroup = Guid.Parse("12345670-0987-0000-0000-000000009007");
            var ReceiptId = Guid.Parse("00000072-ffff-2022-0112-000000000028");

            //var receipt= JsonConvert.DeserializeObject<ModelMID.Receipt>(File.ReadAllText(@"d:\mid\receipt.json "));

            var Pay = new ReceiptPayment[] {
                new ReceiptPayment {
                    Id                = Guid.Parse("9e960928-1070-457d-aec3-14672adf3e9b"),
                    ReceiptId         = ReceiptId,//Guid.Parse("00000072-ffff-2022-0112-000000000007"),
                    PaymentType       = ModernIntegration.Enums.PaymentType.Card,
                    PayIn             = 25.9M,
                    PayOut            = 0.0M,
                    PosPaid           = 25M,
                    CardPan           = "XXXXXXXXXXXX2520",
                    IsPayOutSuccess   = null,
                    TransactionId     = "2",
                    TransactionCode   = "039177601652",
                    InvoiceNumber     = 12345,
                    TransactionStatus = "OK TransactionStatus",
                    PosAuthCode       = "444444444",
                    PosTerminalId     = "PSP0011",
                    CardHolder        = "CardHolder",
                    IssuerName        = "IssuerName",
                    Bank              = "Privat",
                    CreatedAt         = DateTime.Now
                }
            };

            var api = new ApiPSU();


            //   api.GetNoFinishReceipt(TerminalId); return;


            // var rrrr= api.GetReceipts(new DateTime(2022,04,04),new DateTime(2022, 04, 04,23,59,59) , TerminalId);return;
            //api.GetNoFinishReceipt(TerminalId);return


            //var pp = api.AddProductByBarCode(TerminalId, "4820080726777", 1);

            var pp = api.AddProductByProductId(TerminalId, ProductId, 1); return;


            api.ChangeQuantity(TerminalId, pp.Id, 2);

            api.ChangeQuantity(TerminalId, pp.Id, 3);

            api.ChangeQuantity(TerminalId, pp.Id, 1);

            //var rrrrrrrr=api.Bl.db.CloseReceipt(receipt);


            // api.AddPayment(TerminalId, Pay);

            // var xx = api.GetReciept(ReceiptId);            return;
            // var recipt = api.GetProductsByName(TerminalId, "", 0, false, FastGroup,12);

            ProductViewModel sd;

            try
            {
                //sd = api.AddProductByBarCode(TerminalId, "4820240031727",1);
                // var c = api.GetCustomerByPhone(TerminalId, "0667464631");
                //sd = api.AddProductByBarCode(TerminalId, "4820000536202", 1); return;
                //var c = api.GetCustomerByPhone(TerminalId, "0667464631");return;
                //api.Bl.ds.SendReceiptTo1C(new IdReceipt() { CodePeriod = 20210902, IdWorkplace = 74, CodeReceipt = 1}); return;

                //api.Bl.ds.SendRWDeleteAsync();        return;

                //  sd = api.AddProductByBarCode(TerminalId, "5900857007793", 1);
                //try
                //{
                //    sd = api.AddProductByBarCode(TerminalId, "8710671155382", 1);
                //    var recipt = api.GetProductsByName(TerminalId, "", 0, false, FastGroup);
                //    var ddd1 = api.GetProductsByName(TerminalId, "", 1, false, FastGroup);
                //    var ddd2 = api.GetProductsByName(TerminalId, "пом", 0, false, FastGroup);
                //    //return;
                //}
                //catch (Exception e)
                //{
                //    Console.WriteLine(e.Message);
                //}
                //var ccc = api.GetCustomerByPhone(TerminalId,"0666672818");

                //sd = api.AddProductByBarCode(TerminalId, "2211794601924", 1);
                //var QR = await api.Bl.ds.GetQrCoffe(null, 7, 2);
                //Console.WriteLine($"QR=>{QR}");
                //return;
                //var w = api.GetProductsByCategoryId(TerminalId, FastGroup);
                var wwwww = api.GetProductsByName(TerminalId, "БАК", 0, false, FastGroup);

                var sss = api.GetBags();
                var l   = api.AddProductByProductId(TerminalId, ProductId, 3, 55.24M);


                api.AddPayment(TerminalId, Pay);
                //   api.Bl.AddWaresCode(169118, 7, 1);
                Thread.Sleep(2000);
                var rrr = api.GetRecieptByTerminalId(TerminalId, true);

                //Thread.Sleep(6000);

                //            var ssssqq = api.GetQR(TerminalId);

                // sd = api.AddProductByProductId(TerminalId, sd.Id, 1, 45.71M);

                sd = api.AddProductByBarCode(TerminalId, "4820000536202", 8);
                sd = api.AddProductByBarCode(TerminalId, "2510188500004", 8);

                var rgggrr = api.AddProductByProductId(TerminalId, ProductId, 8);

                var clff = api.GetCustomerByBarCode(TerminalId, "8810005077387"); //Моя карточка 7%

                sd = api.AddProductByBarCode(TerminalId, "2201652301489", 1);     //Морква
                                                                                  //Thread.Sleep(2000);
                sd = api.AddProductByBarCode(TerminalId, "7773002160043", 8);     //товар 2 кат
                sd = api.AddProductByBarCode(TerminalId, "4823086109988", 8);

                sd = api.AddProductByBarCode(TerminalId, "2201651902226", 8); //

                var r = api.AddFiscalNumber(TerminalId, "TRRF-1234");         //return;

                var lr = api.Bl.GetLastReceipt();
                api.Bl.CreateRefund(lr); return;

                //   sd = api.AddProductByBarCode(TerminalId, "7775006620509", 1); //товар 2 кат*/
                //  Thread.Sleep(4000);


                //           var clf = api.GetCustomerByBarCode(TerminalId, "8810005077387"); //Моя карточка 7%


                //  return;

                // sd = api.AddProductByBarCode(TerminalId, "8887290101608", 1);  return;

                //var Recvm = api.GetReceiptViewModel(new IdReceipt { CodePeriod = 20200915, IdWorkplace = 72, CodeReceipt = 29 }); return;

                //sd = api.AddProductByBarCode(TerminalId, "7613035603257", 1);
                //Thread.Sleep(2000);
                //return;
                //var c = api.GetCustomerByPhone(TerminalId,"0503729543");
                //var c = api.GetCustomerByBarCode(TerminalId, "8810005077479");
                //var ddd=api.GetReceiptByNumber(TerminalId, "55");



                //api.Bl.ds.SendReceiptTo1C(new IdReceipt() { CodePeriod = 20200920, IdWorkplace = 72, CodeReceipt = 21 }); return;

                api.Bl.GetClientByBarCode(new IdReceipt()
                {
                    CodePeriod = 20201005, IdWorkplace = 68, CodeReceipt = 27
                }, "8810005077387"); return;

                // api.Bl.ds.SendReceiptTo1C(new IdReceipt() { CodePeriod = 20200730, IdWorkplace = 68, CodeReceipt = 8}); return;

                //for(int i = 8720; i<= 8720; i++)
                //api.Bl.ds.SendReceiptTo1C(new IdReceipt() { CodePeriod = 20200706, IdWorkplace = 62, CodeReceipt = i });
                //return;

                //api.Bl.ds.SendReceiptTo1C(new IdReceipt() { CodePeriod = 20200706, IdWorkplace = 62, CodeReceipt = i });

                //sd = api.AddProductByBarCode(TerminalId, "7613036939874", 1);

                sd = api.AddProductByBarCode(TerminalId, "4820000534642", 7);
                sd = api.AddProductByProductId(TerminalId, sd.Id, 4, 10.00M);
                sd = api.AddProductByBarCode(TerminalId, "4820000534741", 8);
                sd = api.AddProductByProductId(TerminalId, sd.Id, 3, 20.00M);

                var rr = api.GetRecieptByTerminalId(TerminalId, true);
                return;

                sd = api.AddProductByBarCode(TerminalId, "4823021808778", 8);

                sd = api.AddProductByBarCode(TerminalId, "1110716760019", 8);   //хліб житній
                                                                                //api.SetWeight(TerminalId, sd.Id, 321);           return;
                sd = api.AddProductByBarCode(TerminalId, "7773002160043", 8);   //товар 2 кат
                                                                                //Thread.Sleep(2000);
                sd = api.AddProductByBarCode(TerminalId, "1110716760019", 8);   //хліб житній
                                                                                // Thread.Sleep(2000);
                sd = api.AddProductByBarCode(TerminalId, "7773002160029", 1);   //товар 2 кат

                var cl = api.GetCustomerByBarCode(TerminalId, "8810005077387"); //Моя карточка 7%

                sd = api.AddProductByBarCode(TerminalId, "2201652301489", 1);   //Морква
                                                                                //Thread.Sleep(2000);
                sd = api.AddProductByBarCode(TerminalId, "7773002160043", 1);   //товар 2 кат

                sd = api.AddProductByBarCode(TerminalId, "2201651902226", 1);   //
                Thread.Sleep(2000);
                //sd = api.AddProductByBarCode(TerminalId, "7775006620509", 1); //товар 2 кат*/
                Thread.Sleep(2000);
                // api.AddFiscalNumber(TerminalId, "1234567");


                //var rrr = api.GetReceipts(DateTime.Parse("2020-06-24T00:00:00"), DateTime.Parse("2020-06-24T23:59:59.999"), TerminalId);
                //            var n = rrr.Count();
                //7667,7676,7677

                //sd = api.AddProductByProductId(TerminalId, ProductId, 1); return;

                sd = api.AddProductByBarCode(TerminalId, "4820207930056", 1); //
                                                                              //sd = api.AddProductByBarCode(TerminalId, "2201651902226", 1); //
                                                                              //sd = api.AddProductByBarCode(Guid.Parse("5c1413f5-66fe-4c2e-9c4c-c354c79952ea"), "7622210653031", 2); //

                var RId = api.GetCurrentReceiptByTerminalId(TerminalId).ReceiptId;
                var Rec = api.GetReciept(RId);

                return;

                /*var rrr=api.GetReceiptViewModel(new IdReceipt {CodePeriod=20200504,IdWorkplace=62,CodeReceipt=12} );
                 *
                 * foreach (var el in rrr.ReceiptItems)
                 *  Console.WriteLine($"{el.ProductName.Substring(0,7)} PP=> {el.ProductPrice } \t Discount=> { el.Discount} \t{el.ProductPrice*el.ProductQuantity*(el.ProductWeightType==ModernIntegration.Enums.ProductWeightType.ByWeight?1000:1 )- el.Discount} "); //FullPrice=>  {el.FullPrice}   TotalPrice=>{el.TotalPrice}
                 */
                //var dddd=api.GetAllCategories(TerminalId);


                //api.Bl.ds.LoadWeightKasa(new DateTime(2020,02,17));return;
                //api.Bl.SendOldReceipt(); return;
                var r2rr = api.GetBags();
                //api.Bl.SendAllReceipt();return;

                sd = api.AddProductByBarCode(TerminalId, "4823086109988", 1); // 1+1 Пельмені "Мішутка" Філейні 600г /Три ведмеді/



                sd = api.AddProductByBarCode(TerminalId, "2206140307779", 1); //



                return;

                //var rrr= api.GetReceipts(DateTime.Parse("2020-02-03T00:00:00"), DateTime.Parse("2020-02-03T23:59:59.999"), TerminalId);

                //Thread.Sleep(1000000);
                //var reseipt = api.GetReceipts(DateTime.Now.Date, DateTime.Now.Date);

                //var cl = api.GetCustomerByBarCode(TerminalId, "8810005077387"); //Моя карточка 7%


                // var rrrr = api.GetNoFinishReceipt(TerminalId);
                //var aa=api.Bl.db.GetConfig<DateTime>("Load_Full__");
                //sd =api.AddProductByBarCode(TerminalId, "4820197006205", 1);
                // sd = api.AddProductByBarCode(TerminalId, "4820198091002", 1);

                //Console.WriteLine("var cl = api.AddProductByBarCode(TerminalId, \"4820048481960\");");
                //Console.WriteLine(sd.Name);
                //          var cl = api.GetCustomerByBarCode(TerminalId, "4820220980229");

                //api.RequestSyncInfo(false);
                //Thread.Sleep(100000);


                sd = api.AddProductByBarCode(TerminalId, "30886", 1);

                var startTime = System.Diagnostics.Stopwatch.StartNew();

                //sd = api.AddProductByBarCode(TerminalId, "4823086109988", 1); // 1+1 Пельмені "Мішутка" Філейні 600г /Три ведмеді/
                //sd = api.AddProductByBarCode(TerminalId, "2201652300489", 1); //Морква
                //Thread.Sleep(1000);

                return;

                sd = api.AddProductByBarCode(TerminalId, "4823000916524", 2); //АРТЕК
                sd = api.AddProductByBarCode(TerminalId, "22970558", 0);
                sd = api.AddProductByBarCode(TerminalId, "7622300813437", 1); //Барн
                sd = api.AddProductByProductId(TerminalId, ProductId, 1);

                sd = api.AddProductByBarCode(TerminalId, "2201652300489", 1); //Морква
                                                                              //Thread.Sleep(1000);
                sd = api.AddProductByBarCode(TerminalId, "2201652300229", 1); //Морква
                                                                              //Thread.Sleep(1000);

                var rssss = api.GetRecieptByTerminalId(TerminalId);

                //Thread.Sleep(1000);
                api.ChangeQuantity(TerminalId, sd.Id, 3);
                //Thread.Sleep(1000);
                api.ChangeQuantity(TerminalId, sd.Id, 4);
                //Thread.Sleep(1000);
                api.ChangeQuantity(TerminalId, sd.Id, 3);
                // Thread.Sleep(1000);
                api.ChangeQuantity(TerminalId, sd.Id, 2);
                //Thread.Sleep(100000);


                //            startTime.Stop();
                //            Console.WriteLine( startTime.Elapsed);
                //            startTime.Restart();

                sd = api.AddProductByBarCode(TerminalId, "1111622770010", 1);

                startTime.Stop();
                Console.WriteLine(startTime.Elapsed);
                startTime.Restart();

                sd = api.AddProductByBarCode(TerminalId, "7622300813437", 2);//Барн

                //startTime.Stop();
                Console.WriteLine(startTime.Elapsed);
                //startTime.Restart();

                //            sd = api.AddProductByBarCode( TerminalId, "2201652300489",1); //Морква

                /*sd = api.AddProductByBarCode(TerminalId, "1110867180018", 1); //Хліб
                 * sd = api.AddProductByBarCode(TerminalId, "40804927", 1);
                 * sd = api.AddProductByBarCode(TerminalId, "1110011760018", 1); //КІВІ ВАГОВІ 2 кат*/
                sd = api.AddProductByBarCode(TerminalId, "2201652300489", 1); //Морква
                sd = api.AddProductByBarCode(TerminalId, "7775006620509", 1); //товар 2 кат
                                                                              //Thread.Sleep(1000);

                /*sd =api.AddProductByBarCode( TerminalId, "5903154545623", 1); //Суміш овочева "Семикомпонентна" 400г /Рудь/ акція 1+1
                 * sd = api.AddProductByBarCode(TerminalId, "7622300813437", 5);//Барн*/
                sd = api.AddProductByBarCode(TerminalId, "4823097403457", 5); //Майонез "Провансаль" 67% д/п 350г /Щедро/
                sd = api.AddProductByBarCode(TerminalId, "4823097405932", 7); //Кетчуп "Лагідний" д/п 250г /Щедро/*/
                api.ChangeQuantity(TerminalId, sd.Id, 0);



                //api.ClearReceipt(TerminalId);
                //var rrrr = api.GetNoFinishReceipt(TerminalId);

                //var RId = api.GetCurrentReceiptByTerminalId(TerminalId).ReceiptId;



                var rr11 = api.GetProduct(TerminalId);


                api.AddPayment(TerminalId, Pay);
                var rrqqrr = api.AddFiscalNumber(TerminalId, "TRRF-1234");

                var ReceiptF = api.GetReciept(RId);

                //var sz = JsonConvert.SerializeObject(receipt);
                // var RefoundReceipt = JsonConvert.DeserializeObject<RefundReceiptViewModel>(sz);
                //RefoundReceipt.IdPrimary = RefoundReceipt.Id;

                //var resRef = api.RefundReceipt(TerminalId, RefoundReceipt);


                //           api.SendReceipt(RId);
                // var Rec=api.GetReciept(RId);


                Console.WriteLine("End");


                //169316+169316 4823086109988 Пельмені "Мішутка" Філейні 600г /Три ведмеді/
                //156727+169583 4823097403457+4823097405932 Майонез "Провансаль" 67% д/п 350г /Щедро/  Кетчуп "Лагідний" д/п 250г /Щедро/
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Ejemplo n.º 2
0
        static async Task Main(string[] args)
        {
            long lastSize = 0;

            "Start".WriteConsoleDebug();

            var dateTime = DateTime.Now;
            var config   = new Config("appsettings.json");

            var receiptName = $"Rc_62_{dateTime.Year}{dateTime.Month:D2}{dateTime.Day:D2}.db";
            var path        = Path.Combine(Global.PathDB, $"{dateTime.Year}{dateTime.Month:D2}", receiptName)
                              .Replace("/", "\\");

            var logPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                       $"{dateTime.Year}_{dateTime.Month}_{dateTime.Day}.log");

            if (File.Exists(path))
            {
                File.Delete(path);
            }
            // для бази в режимі wal
            if (File.Exists(path + "-shm"))
            {
                File.Delete(path + "-shm");
            }

            if (File.Exists(path + "-wal"))
            {
                File.Delete(path + "-wal");
            }

            if (File.Exists(logPath))
            {
                File.Delete(logPath);
            }

            await Task.Delay(10);

            "Config Inited".WriteConsoleDebug();
            var api = new ApiPSU();

            "Api psu inited".WriteConsoleDebug();

            for (int i = 0; i < 10000; i++)
            {
                if (i % 20 == 0)
                {
                    $"Current iteration".WriteConsoleDebug();
                    var LastReceipt = api.Bl.db.db.ExecuteScalar <int>("select max(code_receipt) from RECEIPT");
                    var fi          = new FileInfo(path);

                    var wal = "";
                    if (File.Exists(path + "-wal"))
                    {
                        var fiw = new FileInfo(path + "-wal");
                        wal = $" WAL =>{fiw.LastWriteTime}";
                    }
                    FileLogger.WriteLogMessage($"{i} - db=>{LastReceipt} [{path}]-{fi.LastWriteTime} -{fi.Length}" + wal);
                    if (fi.Length == lastSize)
                    {
                        Console.WriteLine("\n!!!!!!!!!! Error !!!!!!!!!!\n");
                        Console.ReadKey();
                    }
                    lastSize = fi.Length;

                    await api.RequestSyncInfo();
                }

                try
                {
                    var pr = api.AddProductByBarCode(TerminalId, "4820116280075", 1);
                    await Task.Delay(5);

                    pr = api.AddProductByBarCode(TerminalId, "2201652300489", 1);
                    await Task.Delay(5);

                    pr = api.AddProductByBarCode(TerminalId, "7775006620509", 1);
                    await Task.Delay(5);

                    pr = api.AddProductByBarCode(TerminalId, "8810005077387", 1);
                    await Task.Delay(5);

                    var receipt = api.GetRecieptByTerminalId(TerminalId);
                    await Task.Delay(5);

                    var isSucces = api.AddPayment(TerminalId, new[]
                    {
                        new ReceiptPayment
                        {
                            Id                = Guid.NewGuid(),
                            CardPan           = "card",
                            CreatedAt         = DateTime.Now,
                            InvoiceNumber     = i,
                            PayIn             = receipt.TotalAmount,
                            PaymentType       = PaymentType.Card,
                            PayOut            = 0,
                            PosPaid           = receipt.TotalAmount,
                            ReceiptId         = receipt.Id,
                            TransactionCode   = "code",
                            TransactionId     = "trid",
                            TransactionStatus = "status",
                            PosAddAmount      = 0,
                            PosAuthCode       = "auth",
                            PosTerminalId     = "posid",
                        }
                    }, receipt.Id);
                    await Task.Delay(10);

                    isSucces = api.AddFiscalNumber(TerminalId, i.ToString(), receipt.Id);
                    await Task.Delay(10);
                }
                catch (Exception e)
                {
                    $"{e.Message} {e.StackTrace}".WriteConsoleDebug();
                    Console.ReadKey();
                }
                finally
                {
                    $"Current receipt number {i}".WriteConsoleDebug();
                }

                await Task.Delay(500);
            }

            Console.ReadKey();
        }
Ejemplo n.º 3
0
        static void CreateReceipDay()
        {
            var            SQLGetReceipt = @"SELECT top(500) ISNULL(td.PERCENT_DISCOUNT,0) AS PERCENT_DISCOUNT, dc.bar_code,  dr.number,dr.date_time
  ,w.Code_Wares
  ,dbo.GetCodeUnit(ud.code_unit)  AS Code_Unit
  , drw.amount
  ,drw.price
  ,[disc_perc] as disc_perc_manual
  ,drw.sum+drw.sum_bonus AS sum
  ,[disc_perc_auto]
  ,[is_promotion]
  ,dr.comment
  --,drw._Fld11310_RRRef
  ,CONVERT(nchar(32), _Fld17312RRef, 2) AS type_Promotion
  , sc._Description  AS BarCode2Category
 -- COUNT(*) 
  FROM dbo.V1C_doc_receipt dr 
  JOIN dbo.V1C_doc_receipt_wares drw ON dr._IDRRef = drw._IDRRef
  JOIN dbo.Wares w ON drw.nomen_RRef=w._IDRRef
  LEFT JOIN dbo.V1C_DIM_CARD dc ON dr.card_RRef = dc.Card_RRef
  LEFT JOIN dbo.V1C_DIM_TYPE_DISCOUNT TD ON TD.TYPE_DISCOUNT_RRef =DC.TYPE_DISCOUNT_RRef
  JOIN dbo.V1C_dim_addition_unit au ON drw.uom_RRef=au._IDRRef
  JOIN  dbo.V1C_DIM_UNIT_DIMENSION ud ON au.Unit_dimention_RRef=ud.UNIT_DIMENSION_RRef 
  LEFT JOIN   UTPPSU.dbo._Reference18060 sc ON drw.barcode_2 = sc._IDRRef
  WHERE dr._Date_Time BETWEEN CONVERT(DATE,DATEADD(DAY,0,DATEADD(YEAR,2000,GETDATE()))) AND CONVERT(DATE,DATEADD(DAY,1,DATEADD(YEAR,2000,GETDATE())))
  --AND ROUND(drw.amount*drw.price,2)<>drw.sum+drw.sum_bonus
--and is_promotion=1
  AND dr.warehouse_RRef= 0xB7A3001517DE370411DF7DD82E29F000 --
  --AND _Fld17312RRef=0xAF5E2CDABF65241E4EB3EC36EC1F11E2 --Комплект
  --AND _Fld17312RRef=0xA6F61431ECE9ED4646ECAA3A735174ED --По виду дисконтних карт
/*0x8CA05E08A127F853433EF4373AE9DC39 --Скидка на день рождения
0xA19CCECEDC498AF84560C115E6F7418A  --Количество одного товара в документе превысило
0xA6F61431ECE9ED4646ECAA3A735174ED  --По виду дисконтных карт
0xAD63C44DBEEA7E344A9E865F34168F14  --Вторая категория
0xAF5E2CDABF65241E4EB3EC36EC1F11E2  --Комплект*/

  --AND td.PERCENT_DISCOUNT<>[disc_perc_auto]
  --AND dr.number='К1300008702'
--  AND drw.sum_bonus>0
  ORDER BY dr._IDRRef";
            var            TerminalId    = Guid.Parse("abb75469-0f34-4124-8c53-c5392115269d");
            var            Api           = new ApiPSU();
            var            LastLine      = new TestReceipt();
            var            MsSQL         = new WDB_MsSql();
            var            Receipt       = MsSQL.db.Execute <TestReceipt>(SQLGetReceipt);
            IdReceiptWares IdWares;
            var            LastReceipt = new IdReceipt();

            foreach (var L in Receipt)
            {
                IdWares = new IdReceiptWares()
                {
                    CodeWares = L.Code_Wares, CodeUnit = L.Code_Unit
                };

                if (!L.Number.Equals(LastLine.Number))
                {
                    if (LastLine.Number != null)
                    {
                        Api.AddFiscalNumber(LastReceipt.ReceiptId, LastLine.Number);
                    }
                }

                var p = Api.AddProductByProductId(TerminalId, IdWares.WaresId, L.Amount);
                //Api.ChangeQuantity(TerminalId, IdWares.WaresId, L.Amount);

                if (!L.Number.Equals(LastLine.Number))
                {
                    LastReceipt = Api.GetCurrentReceiptByTerminalId(TerminalId);
                    if (L.Bar_Code != null)
                    {
                        Api.GetCustomerByBarCode(TerminalId, L.Bar_Code);
                    }
                    var RH = Api.Bl.GetReceiptHead(LastReceipt);
                    RH.AdditionN1  = L.Percent_Discount;
                    RH.AdditionC1  = L.Number;
                    RH.AdditionD1  = L.Date_Time;
                    RH.DateReceipt = L.Date_Time;

                    Api.Bl.db.ReplaceReceipt(RH);
                }
                var RW  = Api.Bl.db.ViewReceiptWares(LastReceipt);
                var RWE = RW.FirstOrDefault(d => d.CodeWares == L.Code_Wares);
                RWE.AdditionN1       = L.Disc_Perc_Auto;
                RWE.AdditionN2       = L.Sum * (100m - L.Disc_perc_manual) / 100;
                RWE.AdditionN3       = L.Is_Promotion;
                RWE.AdditionC1       = L.Price.ToString() + " " + L.Type_Promotion;
                RWE.BarCode2Category = L.BarCode2Category;
                RWE.Description      = L.Disc_perc_manual.ToString();
                Api.Bl.db.ReplaceWaresReceipt(RWE);

                LastLine = L;
            }
            if (LastLine.Number != null)
            {
                Api.AddFiscalNumber(LastReceipt.ReceiptId, LastLine.Number);
            }
        }