Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainPage"/> class.
        /// </summary>
        public MainPage()
        {
            InitializeComponent();

            this.ViewModel      = new InvoicesViewModel();
            this.BindingContext = this.ViewModel;
        }
Пример #2
0
        // GET: Invoices/Create
        public ActionResult Create()
        {
            ViewBag.ActiveMenu = "Create";

            var customers = db.Customers.ToList();
            var products  = db.Products.ToList();

            var date = DateTime.Now;

            List <InvoiceItem> newInvoiceItems =
                new List <InvoiceItem> {
                new InvoiceItem(),
                new InvoiceItem(),
                new InvoiceItem()
            };

            InvoicesViewModel invoicesViewModel = new InvoicesViewModel()
            {
                Invoice      = new Invoice(),
                Customers    = customers,
                Products     = products,
                InvoiceItems = newInvoiceItems,
            };


            return(View(invoicesViewModel));
        }
Пример #3
0
        // GET: Invoices/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            var invoiceItems = db.InvoiceItems.Where(x => x.InvoiceId == id).Include(i => i.Product).ToList();


            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var invoice = await db.Invoices.Include(i => i.Customer).FirstAsync(x => x.Id == id);

            if (invoice == null)
            {
                return(HttpNotFound());
            }

            InvoicesViewModel invoicesViewModel = new InvoicesViewModel
            {
                Invoice      = invoice,
                InvoiceItems = invoiceItems,
            };

            return(View(invoicesViewModel));
        }
        public async Task <PartialViewResult> GetInvoices(InvoicesViewModel model)
        {
            /*if (model.OverdueCheck.Contains("1") || model.PaidCheck.Contains("0"))
             * {
             *  model.StartDate = new DateTime(2007, 1, 1);
             *  model.EndDate = DateTime.Today;
             * }*/

            if (model.StartDate == DateTime.MinValue)
            {
                model.StartDate = new DateTime(DateTime.Today.AddMonths(-1).Year, DateTime.Today.AddMonths(-1).Month, 1);
            }

            if (model.EndDate == DateTime.MinValue)
            {
                model.EndDate = DateTime.Today;
            }

            var invoices = await this.GetInvoices(this.ActiveCustomer, model.StartDate, model.EndDate);

            //var validCustomers = (await new OverviewDAL().GetCustomersRegistered()).Where(x => x.DatabaseName == ActiveCustomer.DatabaseName && x.CompanyId == ActiveCustomer.CompanyId);
            //invoices = invoices.Join(validCustomers, x => x.InvoiceAccount, y => y.CustomerId, (inv, cust) => inv);

            model.Process(invoices, ActiveCustomer);

            return(PartialView("_InvoicesPartial", model));
        }
Пример #5
0
        public async Task <ActionResult> Create(InvoicesViewModel viewModel)
        {
            if (viewModel.Invoice.Date == null)
            {
                viewModel.Invoice.Date = DateTime.Now;
            }

            var newInvoice = new Invoice
            {
                CustomerId    = viewModel.Invoice.CustomerId,
                Description   = viewModel.Invoice.Description,
                PaymentMethod = viewModel.Invoice.PaymentMethod,
                Date          = viewModel.Invoice.Date,
                Customer      = db.Customers.Find(viewModel.Invoice.CustomerId),
            };

            var newInvoiceId = db.Invoices.Add(newInvoice).Id;

            decimal total = 0;

            foreach (var item in viewModel.InvoiceItems)
            {
                Product product = db.Products.Find(item.ProductId);

                if (product != null && product.Id != 0)
                {
                    var newInvoiceItem = new InvoiceItem()
                    {
                        InvoiceId = newInvoiceId,
                        ProductId = product.Id,
                        Qty       = item.Qty,
                        Price     = product.Price,
                    };

                    total += product.Price * item.Qty;

                    db.InvoiceItems.Add(newInvoiceItem);
                }
                else
                {
                    Debug.WriteLine("No item Selected");
                }
            }

            newInvoice.Id     = newInvoiceId;
            newInvoice.Amount = total;

            db.Invoices.AddOrUpdate(newInvoice);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
            }

            return(RedirectToAction("Details", new { id = newInvoice.Id }));
        }
Пример #6
0
        public ActionResult View_Invoices(string searching, string Searchby)
        {
            if (Session["userId"] == null)
            {
                return(RedirectToAction("Index", "UserHome"));
            }

            InvoicesViewModel m = new InvoicesViewModel();

            m.ReportCount = _ReportService.GetByUnseenStatus().Count();
            if (Searchby == "Buyer Name")
            {
                // m.Invoice = _InvoiceService.GetByMemberId(searching);
            }
            else if (Searchby == "Address")
            {
                // m.Invoice = _InvoiceService.getByAddress(searching);
            }
            else
            {
                m.Invoices = _InvoiceService.GetAll();
            }
            m.members      = _MemberService.GetAll();
            m.InvoiceCount = m.Invoices.Count();

            return(View(m));
        }
        //
        // GET: /Invoices/
        public async Task <ActionResult> Index()
        {
            if (!ActiveCustomer.showMyInvoices)
            {
                return(HttpNotFound());
            }

            DateTime startDate = DateTime.Today.AddMonths(-1);
            DateTime endDate   = DateTime.Today.AddMonths(1);

            if (Session["StartDate"] != null && Session["EndDate"] != null)
            {
                startDate = (DateTime)Session["StartDate"];
                endDate   = (DateTime)Session["EndDate"];
            }
            else
            {
                Session["StartDate"] = startDate;
                Session["EndDate"]   = endDate;
            }

            var invoices = await GetInvoices(this.ActiveCustomer, startDate, endDate);

            //var validCustomers = (await new OverviewDAL().GetCustomersRegistered()).Where(x => x.DatabaseName == ActiveCustomer.DatabaseName && x.CompanyId == ActiveCustomer.CompanyId);
            //invoices = invoices.Join(validCustomers, x => x.InvoiceAccount, y => y.CustomerId, (inv, cust) => inv);

            InvoicesViewModel model = new InvoicesViewModel();

            model.PaidCheck.Add("0");
            model.StartDate = startDate;
            model.EndDate   = endDate;
            model.Process(invoices, ActiveCustomer);
            return(View(model));
        }
Пример #8
0
        public InvoicesViewModel FilterInvoicesVM(InvoicesFilterModel filterModel)
        {
            var invoices = _invoiceService.GetAll();

            if (filterModel != null)
            {
                if (filterModel.DateFrom != null)
                {
                    var dateFrom = DateTime.ParseExact(filterModel.DateFrom, "dd.MM.yyyy", CultureInfo.CreateSpecificCulture("de-DE"));
                    invoices = invoices.Where(x => x.DateIssued >= dateFrom).ToList();
                }
                if (filterModel.DateTo != null)
                {
                    var dateTo = DateTime.ParseExact(filterModel.DateTo, "dd.MM.yyyy", CultureInfo.CreateSpecificCulture("de-DE"));
                    invoices = invoices.Where(x => x.DateIssued <= dateTo).ToList();
                }
            }
            var model = new InvoicesViewModel()
            {
                Invoices = invoices, FilterModel = new InvoicesFilterModel()
            };

            model.Invoices = model.Invoices.OrderByDescending(x => x.Id).ToList();
            var customers = _customersService.GetAll();

            model.FilterModel.Customers = customers.Select(x => new SelectListItem()
            {
                Text  = x.Name,
                Value = x.Id.ToString()
            });
            model.InvoiceStatistics = _invoiceService.GetInvoiceStatistics();
            return(model);
        }
Пример #9
0
        public ActionResult Invoices()
        {
            InvoicesViewModel model = new InvoicesViewModel(GetModelData(),
                                                            _accountProvider.InvoicesGet(UserId()));

            model.Breadcrumbs = GetBreadcrumbs();
            model.CartSummary = GetCartSummary();

            return(View(model));
        }
        public async Task <ActionResult> InvoiceList(InvoicesViewModel model)
        {
            IEnumerable <Invoice> invoices = await GetInvoices(this.ActiveCustomer, model.StartDate, model.EndDate);

            var validCustomers = (await new OverviewDAL().GetCustomersRegistered()).Where(x => x.DatabaseName == ActiveCustomer.DatabaseName && x.CompanyId == ActiveCustomer.CompanyId);

            invoices = invoices.Join(validCustomers, x => x.InvoiceAccount, y => y.CustomerId, (inv, cust) => inv);

            invoices = model.Process(invoices, ActiveCustomer);

            using (var invoicesExport = new ExcelPackage())
            {
                var ws = invoicesExport.Workbook.Worksheets.Add("Table1");

                ws.Cells["A1"].Value = Resources.InvoiceAccount;
                ws.Cells["B1"].Value = Resources.AccountName;
                ws.Cells["C1"].Value = Resources.InvoiceNumber;
                ws.Cells["D1"].Value = Resources.InvoiceDate;
                ws.Cells["E1"].Value = Resources.DueDate;
                ws.Cells["F1"].Value = Resources.Amount;
                ws.Cells["G1"].Value = Resources.VenueName;
                ws.Cells["H1"].Value = Resources.VenueCity;
                ws.Cells["I1"].Value = Resources.Paid;
                ws.Cells["J1"].Value = Resources.InvoiceType;
                ws.Cells["K1"].Value = Resources.YourPurchaseOrder;
                ws.Cells["L1"].Value = Resources.ContactPerson;

                int rowCount = 2;

                for (int i = 0; i < invoices.Count(); i++)
                {
                    ws.Cells["A" + rowCount.ToString()].Value = invoices.ElementAt(i).InvoiceAccount;
                    ws.Cells["B" + rowCount.ToString()].Value = invoices.ElementAt(i).AccountName;
                    ws.Cells["C" + rowCount.ToString()].Value = invoices.ElementAt(i).InvoiceId;
                    ws.Cells["D" + rowCount.ToString()].Value = invoices.ElementAt(i).InvoiceDate;
                    ws.Cells["E" + rowCount.ToString()].Value = invoices.ElementAt(i).DueDate;
                    ws.Cells["F" + rowCount.ToString()].Value = invoices.ElementAt(i).InvoiceAmountMST;
                    ws.Cells["G" + rowCount.ToString()].Value = invoices.ElementAt(i).DeliveryName;
                    ws.Cells["H" + rowCount.ToString()].Value = invoices.ElementAt(i).DeliveryCity;
                    ws.Cells["I" + rowCount.ToString()].Value = invoices.ElementAt(i).IsPaid ? Resources.Yes : Resources.No;
                    ws.Cells["J" + rowCount.ToString()].Value = Invoice.GetSalesTypeName(this.ActiveCustomer.DatabaseName, invoices.ElementAt(i).SalesType, invoices.ElementAt(i).IsHistoric);
                    ws.Cells["K" + rowCount.ToString()].Value = invoices.ElementAt(i).PurchaseOrder;
                    ws.Cells["L" + rowCount.ToString()].Value = invoices.ElementAt(i).ContactPersonName;

                    rowCount++;
                }
                return(File(invoicesExport.GetAsByteArray(), ".xlsx", Resources.Invoices + ".xlsx"));
            };
        }
 public ViewModelLocator()
 {
     if (!DesignerProperties.GetIsInDesignMode(new DependencyObject()))
     {
         MainViewModel             = new MainViewModel();
         HomeViewModel             = new HomeViewModel();
         PaymentsViewModel         = new PaymentsViewModel();
         InvoiceViewModel          = new InvoicesViewModel();
         AddPaymentViewModel       = new AddPaymentViewModel();
         AddInvoiceViewModel       = new AddInvoiceViewModel();
         InvoiceDetailsViewModel   = new InvoiceDetailsViewModel();
         PaymentDetailsViewModel   = new PaymentDetailsViewModel();
         BalanceStatementViewModel = new BalanceStatementViewModel();
     }
 }
Пример #12
0
        public ActionResult View_Invoices()
        {
            if (Session["userId"] == null)
            {
                return(RedirectToAction("Index", "UserHome"));
            }

            InvoicesViewModel m = new InvoicesViewModel();

            m.Invoices     = _InvoiceService.GetAll();
            m.members      = _MemberService.GetAll();
            m.InvoiceCount = _InvoiceService.GetAll().Count();
            m.ReportCount  = _ReportService.GetByUnseenStatus().Count();
            return(View(m));
        }
Пример #13
0
        public InvoicesViewModel PrepareInvoicesVM()
        {
            var invoices = _invoiceService.GetAll();
            var model    = new InvoicesViewModel()
            {
                Invoices = invoices, FilterModel = new InvoicesFilterModel()
            };

            model.Invoices = model.Invoices.OrderByDescending(x => x.Id).ToList();
            var customers = _customersService.GetAll();

            model.FilterModel.Customers = customers.Select(x => new SelectListItem()
            {
                Text  = x.Name,
                Value = x.Id.ToString()
            });
            return(model);
        }
Пример #14
0
        // GET: Invoice
        public async Task <IActionResult> Index(InvoicesViewModel vm1)
        {
            var currency = !string.IsNullOrEmpty(vm1.SelectedCode) ? vm1.SelectedCode : string.Empty;
            var result   = await _invoiceManagerApi.GetAllInvoices(currency, new CancellationToken());

            var currencyCodes = ModelUtils.GetCurrencyCodes().Select(a => new SelectListItem()
            {
                Text     = a.Value,
                Value    = a.Code,
                Selected = false
            });
            var vm = new InvoicesViewModel
            {
                Invoices      = result.Entity,
                CurrencyCodes = currencyCodes,
                SelectedCode  = !string.IsNullOrEmpty(vm1.SelectedCode) ? vm1.SelectedCode : string.Empty
            };

            return(View(vm));
        }
Пример #15
0
 private void btnInvoices_Click(object sender, RoutedEventArgs e)
 {
     DataContext = new InvoicesViewModel();
 }
        public ActionResult Invoices()
        {
            InvoicesViewModel model = new InvoicesViewModel(_accountProvider.InvoicesGet(UserId()));

            return(View(model));
        }
Пример #17
0
        public InvoicesPage()
        {
            InitializeComponent();

            BindingContext = viewModel = new InvoicesViewModel();
        }