Ejemplo n.º 1
0
        private void DoRequestBills()
        {
            BillList.Clear();
            SelectedBill = new BillInfo();
            Predicate <BillInfo> filterByPaidStatus = GetFilterByPaidStatus();
            Predicate <BillInfo> filterByDateTime   = GetFilterByDateTime();
            IList <BillInfo>     bills = new List <BillInfo>();

            try
            {
                bills = _billReaderWriter.GetBillByFilter(bill => filterByPaidStatus(bill) && filterByDateTime(bill));
            }
            catch (Exception e)
            {
                if (PopUpWinService == null)
                {
                    return;
                }

                PopUpWinService.Input = e.Message;
                PopUpWinService.DoModal();
            }

            foreach (BillInfo bill in bills)
            {
                BillList.Add(bill);
            }
        }
Ejemplo n.º 2
0
        private void LoadBills()
        {
            try
            {
                HttpClient client = InitializeClient();

                string              result;
                dynamic             items;
                HttpResponseMessage response;

                // Call the api
                response = client.GetAsync("Bill").Result;

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    // Process the response
                    result = response.Content.ReadAsStringAsync().Result;

                    // REALLY COOL LINE OF CODE HERE
                    items = (JArray)JsonConvert.DeserializeObject(result);
                    bills = items.ToObject <BillList>();
                }
                else
                {
                    throw new Exception("Error: " + response.ReasonPhrase);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 3
0
        public MainPage()
        {
            var billPage = new BillList();

            billPage.Title = "Facturas";

            var clientPage = new ClientList();

            clientPage.Title = "Clientes";

            var productPage = new ProductList();

            productPage.Title = "Productos";



            Children.Add(
                new NavigationPage(billPage)
            {
                Title = "Facturas"
            });
            Children.Add(
                new NavigationPage(clientPage)
            {
                Title = "Clientes"
            });
            Children.Add(
                new NavigationPage(productPage)
            {
                Title = "Productos"
            });
        }
Ejemplo n.º 4
0
        // GET api/<controller>
        public IEnumerable <Bill> Get()
        {
            BillList bills = new BillList();

            bills.Load();
            return(bills);
        }
Ejemplo n.º 5
0
 public TablesClass(ProductsList products, BillList bills,
                    User employee)
 {
     Tables   = new TableList();
     Products = products;
     Bills    = bills;
     Employee = employee;
 }
Ejemplo n.º 6
0
 public void UpdateBillList()
 {
     BillList.Clear();
     foreach (Bill bill in _currentUser.BillList)
     {
         BillList.Add(bill);
     }
 }
        private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            bills = new BillList();

            //      LoadBills();

            //        dgBills.ItemsSource = null;
            //         dgBills.ItemsSource = bills.Where(c => c.UserId == ((BL.User)(cboUser.SelectedItem)).Id);
        }
        public void LoadTest()
        {
            BillList bills = new BillList();

            bills.Load();
            int expected = 3;
            int actual   = bills.Count;

            Assert.AreEqual(expected, actual);
        }
        public void DeleteTest()
        {
            BillList bills = new BillList();

            bills.Load();

            Bill bill   = bills.FirstOrDefault(c => c.BillAmount == 600);
            int  actual = bill.Delete();

            Assert.IsTrue(actual > 0);
        }
Ejemplo n.º 10
0
 public POSSClass(ProductsList products, TableList tables,
                  BillList bills, int index, User employee)
 {
     ProductsToSell          = new ProductToSellList();
     Bills                   = bills;
     Products                = products;
     Tables                  = tables;
     Index                   = index;
     Employee                = employee;
     Tables.Get(Index).InUse = true;
 }
        public void UpdateTest()
        {
            BillList bills = new BillList();

            bills.Load();

            Bill bill = bills.FirstOrDefault(c => c.BillAmount == 500);

            bill.BillAmount = 600;
            bill.Update();


            Assert.AreEqual(bill.BillAmount, 600);
        }
Ejemplo n.º 12
0
        private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            bills = new BillList();

            LoadBills();

            dgBills.ItemsSource = null;
            dgBills.ItemsSource = bills.Where(c => c.UserId == ((BL.User)(cboUser.SelectedItem)).Id);

            dgBills.Columns[0].Visibility = Visibility.Hidden;
            dgBills.Columns[1].Visibility = Visibility.Hidden;
            dgBills.Columns[2].Visibility = Visibility.Hidden;
            dgBills.Columns[3].Visibility = Visibility.Hidden;
            dgBills.Columns[4].Visibility = Visibility.Hidden;
        }
 /// <summary>
 /// Gets the bills credited.
 /// </summary>
 /// <param name="response">The response.</param>
 /// <returns>BillList.</returns>
 internal static BillList getBillsCredited(HttpResponseMessage response)
 {
     var billList = new BillList();
     var jsonObject = JsonConvert.DeserializeObject<Dictionary<string, object>>(response.Content.ReadAsStringAsync().Result);
     if(jsonObject.ContainsKey("bills"))
     {
         var billsArray = JsonConvert.DeserializeObject<List<object>>(jsonObject["bills"].ToString());
         foreach(var billObject in billsArray)
         {
             var bill = new Bill();
             bill = JsonConvert.DeserializeObject<Bill>(billObject.ToString());
             billList.Add(bill);
         }
     }
     return billList;
 }
Ejemplo n.º 14
0
        public MainWindow()
        {
            InitializeComponent();
            try
            {
                bills = new BillList();
                bills.Load();

                dgvBills.ItemsSource = null;
                dgvBills.ItemsSource = bills;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Gets the bills credited.
        /// </summary>
        /// <param name="response">The response.</param>
        /// <returns>BillList.</returns>
        internal static BillList getBillsCredited(HttpResponseMessage response)
        {
            var billList   = new BillList();
            var jsonObject = JsonConvert.DeserializeObject <Dictionary <string, object> >(response.Content.ReadAsStringAsync().Result);

            if (jsonObject.ContainsKey("bills"))
            {
                var billsArray = JsonConvert.DeserializeObject <List <object> >(jsonObject["bills"].ToString());
                foreach (var billObject in billsArray)
                {
                    var bill = new Bill();
                    bill = JsonConvert.DeserializeObject <Bill>(billObject.ToString());
                    billList.Add(bill);
                }
            }
            return(billList);
        }
Ejemplo n.º 16
0
        public ActionResult List(DateTime bDate, DateTime eDate, int codeID = 0)
        {
            ViewBag.BeginDate = bDate;
            ViewBag.EndDate   = eDate;
            ViewBag.BillID    = codeID;

            IEnumerable <bill> BillList;

            if (codeID > 0)
            {
                BillList = billRepository.GetBillByPayeeDateRange(codeID, bDate.Date, eDate.Date);
            }
            else
            {
                BillList = billRepository.GetBillByDueDateRange(bDate.Date, eDate.Date);
            }

            ViewBag.RecordCount = BillList.Count();
            return(PartialView(BillList));
        }
Ejemplo n.º 17
0
        public MainWindow()
        {
            InitializeComponent();
            bills = new BillList();
            LoadBills();

            LoadUsers();

            cboUser.ItemsSource       = null;
            cboUser.ItemsSource       = users;
            cboUser.DisplayMemberPath = "FullName";
            cboUser.SelectedValuePath = "Id";


            LoadDestinations();

            cboBillDestination.ItemsSource       = null;
            cboBillDestination.ItemsSource       = billDestinations;
            cboBillDestination.DisplayMemberPath = "BusinessName";
            cboBillDestination.SelectedValuePath = "Id";
        }
Ejemplo n.º 18
0
 internal static BillList getBillList(HttpResponseMessage responce)
 {
     var billList = new BillList();
     var jsonObj = JsonConvert.DeserializeObject<Dictionary<string, object>>(responce.Content.ReadAsStringAsync().Result);
     if (jsonObj.ContainsKey("bills"))
     {
         var billsArray = JsonConvert.DeserializeObject<List<object>>(jsonObj["bills"].ToString());
         foreach(var billObj in billsArray)
         {
             var bill = new Bill();
             bill = JsonConvert.DeserializeObject<Bill>(billObj.ToString());
             billList.Add(bill);
         }
     }
     if (jsonObj.ContainsKey("page_context"))
     {
         var pageContext = new PageContext();
         pageContext = JsonConvert.DeserializeObject<PageContext>(jsonObj["page_context"].ToString());
         billList.page_context = pageContext;
     }
     return billList;
 }
Ejemplo n.º 19
0
        internal static BillList getBillList(HttpResponseMessage responce)
        {
            var billList = new BillList();
            var jsonObj  = JsonConvert.DeserializeObject <Dictionary <string, object> >(responce.Content.ReadAsStringAsync().Result);

            if (jsonObj.ContainsKey("bills"))
            {
                var billsArray = JsonConvert.DeserializeObject <List <object> >(jsonObj["bills"].ToString());
                foreach (var billObj in billsArray)
                {
                    var bill = new Bill();
                    bill = JsonConvert.DeserializeObject <Bill>(billObj.ToString());
                    billList.Add(bill);
                }
            }
            if (jsonObj.ContainsKey("page_context"))
            {
                var pageContext = new PageContext();
                pageContext           = JsonConvert.DeserializeObject <PageContext>(jsonObj["page_context"].ToString());
                billList.page_context = pageContext;
            }
            return(billList);
        }
Ejemplo n.º 20
0
        public async Task <ActionResult <BillList> > CreateBill(int id, int cardId)
        {
            BillList billList = new BillList()
            {
                bill         = _context.Bills.Find(id),
                billProducts = _context.BillProducts.Where(x => x.BillId == id).ToList()
            };

            billList.bill.CardId = cardId;

            List <BillProduct> billProducts = billList.billProducts;

            if (billProducts == null || billProducts.Count == 0)
            {
                return(BadRequest());
            }
            using (var transaction = _context.Database.BeginTransaction())
            {
                //foreach (BillProduct billProduct in billProducts)
                //{
                //    billProduct.BillId = billList.bill.BillId;
                //}
                //_context.BillProducts.AddRange(billProducts);
                //await _context.SaveChangesAsync();

                double sum      = 0.0;
                double discount = 0.0;
                foreach (BillProduct billProduct in billProducts)
                {
                    sum += billProduct.Amount * _context.Products.Find(billProduct.ProductId).BasePrice;
                    List <CardWaste>    wasteBalances = _context.CardWastes.Where(x => x.CardId == billList.bill.CardId).ToList();
                    List <ProductWaste> productWastes = _context.ProductWastes.Where(x => x.ProductId == billProduct.ProductId).ToList();

                    foreach (ProductWaste productWaste in productWastes)
                    {
                        double    totalAmount = productWaste.Amount * billProduct.Amount;
                        CardWaste cardWaste   = wasteBalances.FirstOrDefault(x => x.WasteId == productWaste.WasteId);
                        totalAmount -= cardWaste.Amount;
                        if (totalAmount >= 0)
                        {
                            cardWaste.Amount -= productWaste.Amount * billProduct.Amount - totalAmount;
                        }
                        else
                        {
                            cardWaste.Amount = -totalAmount;
                            totalAmount      = 0;
                        }
                        _context.Entry(cardWaste).State = EntityState.Modified;
                        await _context.SaveChangesAsync();

                        discount += (productWaste.Amount * billProduct.Amount - totalAmount) * productWaste.Waste.RecyclingPrice;
                        _context.BillProductWastes.Add(new BillProductWaste {
                            BillProductId = billProduct.Id, WasteId = productWaste.WasteId, DiscountedAmount = productWaste.Amount * billProduct.Amount - totalAmount
                        });
                        await _context.SaveChangesAsync();
                    }
                }
                double total = sum - discount;
                if (_context.Cards.Find(billList.bill.CardId).Balance < total)
                {
                    transaction.Rollback();
                    return(StatusCode(402));
                }
                billList.bill.Discount              = discount;
                billList.bill.Total                 = total;
                billList.bill.IsCompleted           = true;
                _context.Entry(billList.bill).State = EntityState.Modified;
                _context.Cards.Find(billList.bill.CardId).Balance -= total;
                await _context.SaveChangesAsync();

                transaction.Commit();
            }
            return(Redirect("Details/" + billList.bill.BillId));
        }
Ejemplo n.º 21
0
        public async Task <PagingDataSource <Bill> > Get(ODataQueryOptions <Bill> options, [FromUri] BillList req)
        {
            BillService.DisableProxy();

            var listBill = BillService.GetAll();

            if (req != null && req.Includes != null && req.Includes.Length > 0)
            {
                listBill = Include(listBill, req.Includes);
            }

            var ls = (IQueryable <Bill>)options.ApplyTo(listBill);

            var retVal = new PagingDataSource <Bill>();

            retVal.Data = await ls.Cast <Bill>().ToListAsync();

            retVal.Total = Request.GetInlineCount() ?? 0;

            return(retVal);
        }