Exemplo n.º 1
0
        public IHttpActionResult Post(ReceiptPayment editPayment)
        {
            var ua = UserAccess.GetUserAccess(User.Identity.Name);

            if (!ua.cashier_access)
            {
                return(Unauthorized());
            }

            if (editPayment == null)
            {
                return(Ok(BadRequest("There are no payments to edit")));
            }

            var errors          = new List <string>();
            var originalPayment = ReceiptPayment.GetPaymentsByPayId(editPayment.PayId).DefaultIfEmpty(new ReceiptPayment()).First();

            var cashierId = originalPayment.CashierId;

            errors = ReceiptPayment.EditPaymentValidation(editPayment, originalPayment);

            if (errors.Count() == 0)
            {
                errors = ReceiptPayment.UpdatePayments(editPayment, originalPayment, ua.user_name);
            }

            var response = new ClientResponse(cashierId)
            {
                Errors = errors
            };

            return(Ok(response));
        }
Exemplo n.º 2
0
        public JsonResult CreateReceipt(ReceiptPayment receipt)
        {
            ReceiptPayment        onlyReceiptPayment = new ReceiptPayment();
            List <PatientService> listPatientService = receipt.PatientServices.ToList();

            receipt.PatientServices = null;



            receipt.UserId = GetLoggedinUserInfo().UserId;

            using (Repository <ReceiptPayment> repository = new Repository <ReceiptPayment>())
            {
                onlyReceiptPayment = repository.Insert(receipt);
                repository.Commit();
            }
            foreach (PatientService sitem in listPatientService)
            {
                sitem.UserId    = GetLoggedinUserInfo().UserId;;
                sitem.ReceiptId = onlyReceiptPayment.Id;
                sitem.Item      = null;

                using (PatientServiceRepository patientservicerepository = new PatientServiceRepository())
                {
                    patientservicerepository.Update(sitem);
                    patientservicerepository.Commit();
                }
            }

            return(Json(onlyReceiptPayment, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public ActionResult Add(string key)
        {
            var msg   = new JsonMessage(false, "Thêm mới dữ liệu thành công.");
            var model = new ReceiptPayment();

            try
            {
                if (key != Keyapi)
                {
                    return(Json(0, JsonRequestBehavior.AllowGet));
                }
                UpdateModel(model);
                model.Note     = HttpUtility.UrlDecode(model.Note);
                model.IsDelete = false;
                model.IsActive = false;
                model.Code     = DateTime.Now.ToString("yyMMddHHmmss");
                var startDate = Request["DateReturn_"];
                model.DateReturn  = startDate.StringToDecimal();
                model.DateCreated = DateTime.Now.TotalSeconds();
                _da.Add(model);
                _da.Save();
            }
            catch (Exception ex)
            {
                msg.Erros   = true;
                msg.Message = "Dữ liệu chưa được thêm mới.";
                Log2File.LogExceptionToFile(ex);
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
        public JsonResult SaveRecieptPayment(ReceiptPayment receipt)
        {
            Payment payment = receipt.Payment;

            receipt.Payment = null;
            ReceiptPayment        onlyReceipt         = new ReceiptPayment();
            List <PatientService> onlyPatientServices = new List <PatientService>();


            onlyPatientServices     = receipt.PatientServices.ToList();
            receipt.PatientServices = null;

            List <PatientService> pService = onlyPatientServices;


            using (PaymentRepository repository = new PaymentRepository())
            {
                payment.UserId = GetLoggedinUserInfo().UserId;

                payment = repository.Insert(payment);
                repository.Commit();
                // CreatePatientService(invoice.Id, patientServices);
            }

            receipt.PaymentId = payment.Id;

            using (Repository <ReceiptPayment> repository = new Repository <ReceiptPayment>())
            {
                onlyReceipt.UserId = GetLoggedinUserInfo().UserId;
                onlyReceipt        = repository.Update(receipt);
                repository.Commit();
            }

            using (Repository <PatientService> repository = new Repository <PatientService>())
            {
                foreach (PatientService item in pService)
                {
                    item.Item   = null;
                    item.UserId = GetLoggedinUserInfo().UserId;
                    repository.Update(item);
                    repository.Commit();
                }
            }
            onlyReceipt.PatientServices = onlyPatientServices;

            return(Json(onlyReceipt, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 5
0
 /// <summary>
 /// Convert ReceiptPayment->Payment
 /// </summary>
 /// <param name="pRP"></param>
 /// <returns></returns>
 public Payment ReceiptPaymentToPayment(IdReceipt parIdReceipt, ReceiptPayment pRP)
 {
     return(new Payment(parIdReceipt)
     {
         TypePay = (eTypePay)(int)pRP.PaymentType,
         SumPay = pRP.PayIn,
         NumberReceipt = pRP.InvoiceNumber,       //parRP.TransactionId,
         NumberCard = pRP.CardPan,
         CodeAuthorization = pRP.TransactionCode, //RRN
         NumberTerminal = pRP.PosTerminalId,
         NumberSlip = pRP.PosAuthCode,            //код авторизації
         PosPaid = pRP.PosPaid,
         PosAddAmount = pRP.PosAddAmount,
         DateCreate = pRP.CreatedAt,
         CardHolder = pRP.CardHolder,
         IssuerName = pRP.IssuerName,
         Bank = pRP.Bank,
         TransactionId = pRP.TransactionId
     });
 }
Exemplo n.º 6
0
 public void Delete(ReceiptPayment item)
 {
     FDIDB.ReceiptPayments.Remove(item);
 }
Exemplo n.º 7
0
 public void Add(ReceiptPayment item)
 {
     FDIDB.ReceiptPayments.Add(item);
 }
Exemplo n.º 8
0
        //public JsonResult GetInvoicesByPatientID(long id)
        //{
        //    using (PatientInvoiceRepository repository = new PatientInvoiceRepository())
        //    {
        //        List<PatientInvoice> patientInvoice = repository.GetByQuery().ToList();

        //    }

        //    return Json("invoice loaded success fully");

        //}=""

        public JsonResult GetReceiptByPatientId(long patientid, long?receiptId = null)
        {
            List <ReceiptPayment> receipt;
            List <ReceiptPayment> onlyReceipt = new List <ReceiptPayment>();

            using (Repository <ReceiptPayment> repository = new Repository <ReceiptPayment>())
            {
                Expression <Func <ReceiptPayment, bool> > lambda;

                Func <IQueryable <ReceiptPayment>, IOrderedQueryable <ReceiptPayment> > orderingFunc = query => query.OrderByDescending(m => m.Id);


                lambda  = (x => x.Active == true && x.PatientId == patientid && (receiptId == null ? x.Id > 0 : x.Id == receiptId));
                receipt = repository.GetByQuery(lambda, orderingFunc).ToList();



                foreach (ReceiptPayment item in receipt)
                {
                    ReceiptPayment itemReceipt    = new ReceiptPayment();
                    Payment        receiptPayment = new Payment();

                    itemReceipt.Payment = receiptPayment;

                    itemReceipt.Id            = item.Id;
                    itemReceipt.PaymentId     = item.PaymentId;
                    itemReceipt.PatientId     = item.PatientId;
                    itemReceipt.ReceiptDate   = item.ReceiptDate;
                    itemReceipt.TotalAmount   = item.TotalAmount;
                    itemReceipt.TotalDiscount = item.TotalDiscount;
                    itemReceipt.IsRefunded    = item.IsRefunded;

                    if (item.Payment != null)
                    {
                        itemReceipt.Payment.Amount = item.Payment.Amount;
                    }
                    else
                    {
                        itemReceipt.Payment.Amount = 0;
                    }


                    foreach (PatientService c in item.PatientServices)
                    {
                        PatientService patientstitem = new PatientService();

                        Item sitem = new Item();

                        ItemCategory Category = new ItemCategory();

                        patientstitem.Item = sitem;
                        patientstitem.Item.ItemCategory = Category;


                        patientstitem.Id                   = c.Id;
                        patientstitem.PatientID            = c.PatientID;
                        patientstitem.ItemId               = c.ItemId;
                        patientstitem.InvoiceID            = c.InvoiceID;
                        patientstitem.ReceiptId            = c.ReceiptId;
                        patientstitem.PatientAdmissionId   = c.PatientAdmissionId;
                        patientstitem.ServiceListPrice     = c.ServiceListPrice;
                        patientstitem.ServiceActualPrice   = c.ServiceActualPrice;
                        patientstitem.ServiceQuantity      = c.ServiceQuantity;
                        patientstitem.ServiceDate          = c.ServiceDate;
                        patientstitem.UserId               = c.UserId;
                        patientstitem.Discount             = c.Discount;
                        patientstitem.DiscountAfterInvoice = c.DiscountAfterInvoice;
                        patientstitem.Refund               = c.Refund;
                        patientstitem.RefundNote           = c.RefundNote;

                        patientstitem.Billed       = c.Billed;
                        patientstitem.LabStatusId  = c.LabStatusId;
                        patientstitem.ReferralFee  = c.ReferralFee;
                        patientstitem.DeliveryDate = c.DeliveryDate;
                        patientstitem.DeliveryTime = c.DeliveryTime;


                        patientstitem.Item.Name        = c.Item.Name;
                        patientstitem.Item.GenericName = c.Item.GenericName;
                        if (c.Item.ItemCategory != null)
                        {
                            patientstitem.Item.ItemCategory.Name = c.Item.ItemCategory.Name;
                        }

                        itemReceipt.PatientServices.Add(patientstitem);
                    }

                    onlyReceipt.Add(itemReceipt);
                }
            }

            if (onlyReceipt.Count == 0)
            {
                return(Json(HttpNotFound(), JsonRequestBehavior.AllowGet));
            }
            return(Json(onlyReceipt, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 9
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);
            }
        }
Exemplo n.º 10
0
        private CashRegisterReceipt CreateReceipt()
        {
            // lets create receipt object - the single required parameter is the cash registe code.
            // all other parameters are optional.

            CashRegisterReceipt receipt = new CashRegisterReceipt(this.cashRegisterCode)
            {
                // Optional text, printed between informations about company and items
                HeaderText = "Web: www.ninedigit.sk",
                // Optional text, that is printed at the end of the receipt
                FooterText = "Ďakujeme za nákup.",
            };

            // lets add some items (products) to the receipt - as receipt must have at least one.

            // helper object to contains receipt item data.
            ReceiptItemData itemData = new ReceiptItemData()
            {
                Type      = ReceiptItemType.Positive,
                Name      = "Banány voľné",
                UnitPrice = 1.123456m,                  // unit price can be specified up to 6 decimal places
                Quantity  = new Quantity(0.123m, "kg"), // quantity can be specified up to 3 decimal places
                Price     = 0.14m,                      // price must be equal to unitPrice * quantity, and can be specified up to 2 decimal places. Mathematical rounding is applied.
                VatRate   = VatRate.Free
            };

            // this data object has its validator, so we can check, whether our application composes receipt item correctly.
            ValidationResult itemDataValidationResult = itemData.Validate();

            if (!itemDataValidationResult.IsValid)
            {
                // object is invalid - that means, we did something wrong!

                // to see more details, inspect the errors collection.
                IEnumerable <MemberValidationFailure> errors = itemDataValidationResult.Errors;

                // lets pick first error and throw an exception.
                MemberValidationFailure firstError = errors.First();

                string errorMessage = $"Invalid composition of ticket item. {firstError.MemberName}: {firstError.Message}";
                throw new InvalidOperationException(errorMessage);
            }

            // after validation succeeds, we can create receipt item
            ReceiptItem receiptItem = new ReceiptItem(itemData);

            // add item to receipt.
            receipt.Items.Add(receiptItem);

            // we don't need to specify payments. But if we do, their amounts must be equal or greater than total amount of receipt.

            // prepare empty payments collection
            receipt.Payments = new ReceiptPayments();

            // and add some payments
            ReceiptPayment payment1 = new ReceiptPayment("Hotovosť", 1m); // "Hotovosť" means "cash"

            receipt.Payments.Add(payment1);

            // cash to return can be stated as another payment, with negative amount.
            ReceiptPayment payment2 = new ReceiptPayment("Hotovosť", -0.86m);

            receipt.Payments.Add(payment2);

            return(receipt);
        }
Exemplo n.º 11
0
        public ActionResult Actions()
        {
            var msg = new JsonMessage {
                Erros = false, Message = "Cập nhật dữ liệu thành công !"
            };
            var model = new ReceiptPayment();
            var lst   = new List <ReceiptPayment>();

            switch (DoAction)
            {
            case ActionType.Add:
                try
                {
                    UpdateModel(model);
                    model.IsDelete = false;
                    model.IsActive = false;
                    var startDate = Request["DateReturn_"];
                    var date      = ConvertUtil.ToDateTime(startDate);
                    model.DateReturn  = ConvertDate.TotalSeconds(date);
                    model.DateCreated = ConvertDate.TotalSeconds(DateTime.Now);
                    _da.Add(model);
                    _da.Save();
                }
                catch (Exception ex)
                {
                    msg.Erros   = true;
                    msg.Message = "Có lỗi xảy ra!";
                }
                break;

            case ActionType.Edit:
                try
                {
                    model = _da.GetById(ArrId.FirstOrDefault());
                    UpdateModel(model);
                    var startDate = Request["DateReturn_"];
                    var date      = ConvertUtil.ToDateTime(startDate);
                    model.DateReturn = ConvertDate.TotalSeconds(date);
                    _da.Save();
                }
                catch (Exception ex)
                {
                    msg.Erros   = true;
                    msg.Message = "Có lỗi xảy ra!";
                }
                break;

            case ActionType.Active:
                try
                {
                    lst = _da.GetListArrId(ArrId);
                    foreach (var item in lst)
                    {
                        item.IsActive = true;
                    }
                    _da.Save();
                    msg.Message = "Đơn đặt hàng đã được duyệt !";
                }
                catch (Exception ex)
                {
                    msg.Erros   = true;
                    msg.Message = "Duyệt đơn hàng thất bại !";
                }
                break;

            case ActionType.Delete:

                lst = _da.GetListArrId(ArrId);
                foreach (var item in lst)
                {
                    item.IsDelete = true;
                }
                _da.Save();
                return(Json(1, JsonRequestBehavior.AllowGet));
            }
            if (string.IsNullOrEmpty(msg.Message))
            {
                msg.Message = "Không có hành động nào được thực hiện.";
                msg.Erros   = true;
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }