public InvoiceListControl(InvoiceListModel model) { InitializeComponent(); _presenter = new InvoiceListPresenter(this, model); gvInvoice.PopupMenuShowing += gvInvoice_PopupMenuShowing; gvInvoice.FocusedRowChanged += gvInvoice_FocusedRowChanged; // init editor control accessibility cmsAddData.Enabled = AllowInsert; cmsEditData.Enabled = AllowEdit; cmsPrint.Enabled = AllowEdit; cmsAddReturn.Enabled = AllowEdit; if (LoginInformation.RoleName == DbConstant.ROLE_SUPERADMIN) { btnRepairAll.Visible = true; } else { btnRepairAll.Visible = false; } this.Load += InvoiceListControl_Load; }
public ActionResult SearchInvoiceList(InvoiceSearchFieldModel srchModel, int page) { try { int pageSize = 5; var data = new PagedData <InvoiceSearchResultModel>(); InvoiceListModel model = new InvoiceListModel(); ProjectService _ps = new ProjectService(); if (srchModel.ToDate != null) { DateTime todate = (DateTime)srchModel.ToDate; srchModel.ToDate = todate.Date.AddDays(1).AddTicks(-1); } //else if (srchModel.ToCreateDate != null) //{ // DateTime todate = (DateTime)srchModel.ToCreateDate; // srchModel.ToCreateDate = todate.Date.AddDays(1).AddTicks(-1); //} data = _ps.GetInvoiceList(srchModel, page, pageSize); model.SearchResult = data; return(PartialView(model)); } catch (Exception ex) { return(RedirectToAction("DashBoard", "Home")); } }
public void InvoicePDF_Failed_Returns_Catch_RedirectToAction_Error() { InvoiceListModel model = new InvoiceListModel { Id = 1, InvoiceId = 1 }; Users user = new Users { Id = 1, UserName = "******" }; var cancel = new CancellationToken(); var mockProductService = new Mock <IProductService>(); var mockUserService = new Mock <IUserService>(); var mockOrderService = new Mock <IOrderService>(); var mockUserStore = new Mock <IUserStore <Users> >(); mockUserStore.Setup(u => u.CreateAsync(user, cancel)); var mockManager = new Mock <UserManager <Users> >(mockUserStore.Object, null, null, null, null, null, null, null, null); var Controller = new OrderProcessingController(mockProductService.Object, mockManager.Object, mockUserService.Object, mockOrderService.Object); var result = Controller.InvoicePdf(model); var viewResult = Assert.IsType <RedirectToActionResult>(result); }
public async Task List_invoices() { // Arrange InvoiceListModel invoices = null; // Act using (var apiInvoice = new Invoice()) { invoices = await apiInvoice.GetAsync().ConfigureAwait(false); }; // Assert Assert.That(invoices, Is.Not.Null); Assert.That(invoices?.items, Is.Not.Empty); }
public async Task <IActionResult> SearchForInvoice(DataSourceRequest command, InvoiceListModel model) { //temp model.intClientID = (int)_workContext.CurrentCustomer.ClientId; var(InvoiceModelList, totalCount) = await _invoiceManagementService.PrepareInvoiceFindListModel(model, command.Page, command.PageSize); var gridModel = new DataSourceResult { Data = InvoiceModelList, Total = totalCount }; return(Json(gridModel)); }
public IActionResult InvoicePdf(InvoiceListModel listModel) { try { var invoice = _orders.GetInvoice(listModel.InvoiceId); var orders = _orders.GetOrderByInvoiceId(invoice.Id); if (orders.Count() > 0) { var first = orders.First(); var blInfo = _orders.GetBillingInfoById(first.BillingInfoId); var user = _users.GetUserById(first.UserId); var ordersToAdd = orders.Select(o => new OrderModel { Id = o.Id, Item = _products.GetById(o.ItemId), Manufacturer = _products.GetProductName(o.Items.Id), Model = _products.GetModelName(o.ItemId), NumberOfItems = o.NumberOfItems, }); var invoiceToAdd = new InvoiceModel { Orders = ordersToAdd, Customer = user.Result, BillingInfo = blInfo, InvoiceDate = DateTimeOffset.Now, PaymentMethod = _orders.GetPaymentMethod(first.PaymentMethodId) }; return(new ViewAsPdf("InvoicePdf", invoiceToAdd)); } else { return(RedirectToAction("Error", "Home", new { errorDetail = "Invoice Not Found!" })); } } catch { return(RedirectToAction("Error", "Home", new { errorDetail = "Something went wrong!" })); } }
public async Task Resend_invoice_mail() { // Arrange InvoiceListModel invoices = null; InvoiceModel resendInvoiceModel = null; var resendInvoiceId = ""; // Act using (var apiInvoice = new Invoice()) { invoices = await apiInvoice.GetAsync().ConfigureAwait(false); resendInvoiceId = invoices.items.First().id; resendInvoiceModel = await apiInvoice.ResendInvoiceMail(resendInvoiceId).ConfigureAwait(false); }; // Assert Assert.That(resendInvoiceModel, Is.Not.Null); Assert.That(resendInvoiceModel.id, Is.EqualTo(resendInvoiceId)); }
public IActionResult InvoiceList(OrderListModel model) { var user = _users.GetUserById(model.UserId); var invoices = _orders.GetInvoices(user.Result.UserName); var invoicesToAdd = invoices.Select(i => new Invoice { Id = i.Id, InvoiceDate = i.InvoiceDate, User = i.User, Orders = i.Orders }); var invoice = new InvoiceListModel { Invoices = invoicesToAdd }; return(View(invoice)); }
public async Task <(IEnumerable <InvoiceFind> InvoiceModelList, int totalCount)> PrepareInvoiceFindListModel(InvoiceListModel model, int pageIndex, int pageSize) { try { var query = _historyRepository.Table; if (!string.IsNullOrEmpty(model.strHPO)) { query = query.Where(c => c.Hpo.Equals(model.strHPO)); } if (!string.IsNullOrEmpty(model.txtHDateB)) { query = query.Where(c => Convert.ToDateTime(model.txtHDateB) <= c.Hdate); } if (!string.IsNullOrEmpty(model.txtHDateE)) { query = query.Where(c => Convert.ToDateTime(model.txtHDateE) >= c.Hdate); } if (!string.IsNullOrEmpty(model.strShipID)) { query = query.Where(c => c.HshipName.Equals(model.strShipID)); } if (!string.IsNullOrEmpty(model.strVendor)) { query = query.Where(c => c.HvendorName.ToLower().Trim().Equals(model.strVendor.ToLower().Trim())); } if (!string.IsNullOrEmpty(model.strInvoice)) { query = query.Where(c => c.Hinvoice.Equals(model.strInvoice)); } query = query.OrderByDescending(c => c.HistoryId); var items = query; var invoiceList = new List <InvoiceFind>(); foreach (var item in items) { invoiceList.Add(new InvoiceFind { HInvoice = string.IsNullOrEmpty(item.Hinvoice) ? "None" : item.Hinvoice, HClientID = item.HclientId, HDate = Convert.ToDateTime(item.Hdate).ToString("MM/dd/yyyy hh:mm tt"), HPO = item.Hpo, HOItem = item.Hoitem, HDescription = item.Hdescription, HVendorName = item.HvendorName, HistoryID = item.HistoryId, HShipID = item.HshipId, }); } int totalCount = invoiceList.Count; int pageOffSet = (Convert.ToInt32(pageIndex) - 1) * 10; invoiceList = invoiceList.Skip(pageOffSet).Take(Convert.ToInt32(pageSize)).ToList(); return(invoiceList, totalCount); } catch (Exception ex) { } return(null, 0); }
public ActionResult ProformaInvoice() { try { var loggedinuser = User.Identity.Name; var user = Common.getUserIdAndRole(loggedinuser); int logged_in_userid = user.Item1; int user_role = user.Item2; //if (user_role == 8) //{ int page = 1; int pageSize = 5; ViewBag.PIName = Common.GetPIWithDetails(); var ptypeList = Common.getprojecttype(); int firstPType = ptypeList != null ? ptypeList[0].codevalAbbr : 0; ViewBag.ProjectTypeList = ptypeList; var invoicetype = Common.getinvoicetype(); var Invoice = Common.GetProformaInvoicedetails(); var emptyList = new List <MasterlistviewModel>(); ViewBag.ProjectNumberList = emptyList; ViewBag.TypeofInvoice = invoicetype; ViewBag.Invoice = Invoice; var data = new PagedData <InvoiceSearchResultModel>(); InvoiceListModel model = new InvoiceListModel(); ProjectService _ps = new ProjectService(); InvoiceSearchFieldModel srchModel = new InvoiceSearchFieldModel(); data = _ps.GetProformaInvoiceList(srchModel, page, pageSize); model.Userrole = user_role; model.SearchResult = data; return(View(model)); //} //if (user_role == 7) //{ // int page = 1; // int pageSize = 5; // ViewBag.PIName = Common.GetPIWithDetails(); // var Projecttitle = Common.GetPIProjectdetails(logged_in_userid); // var projecttype = Common.getprojecttype(); // var invoicetype = Common.getinvoicetype(); // var Invoice = Common.GetInvoicedetails(); // ViewBag.Project = Projecttitle; // ViewBag.projecttype = projecttype; // ViewBag.TypeofInvoice = invoicetype; // ViewBag.Invoice = Invoice; // var data = new PagedData<InvoiceSearchResultModel>(); // InvoiceListModel model = new InvoiceListModel(); // ProjectService _ps = new ProjectService(); // InvoiceSearchFieldModel srchModel = new InvoiceSearchFieldModel(); // srchModel.PIName = logged_in_userid; // data = _ps.GetPIInvoiceList(srchModel, page, pageSize); // model.Userrole = user_role; // model.SearchResult = data; // return View(model); //} //return RedirectToAction("DashBoard", "Home"); } catch (Exception ex) { return(RedirectToAction("DashBoard", "Home")); } }
public ActionResult InvoiceList(DataSourceRequest command, InvoiceListModel model) { //if (!_permissionService.Authorize(StandardPermissionProvider.ManageOrders)) // return AccessDeniedView(); //a vendor should have access only to his products if (_workContext.CurrentVendor != null) { model.VendorId = _workContext.CurrentVendor.Id; } DateTime?startDateValue = (model.StartDate == null) ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.StartDate.Value, _dateTimeHelper.CurrentTimeZone); DateTime?endDateValue = (model.EndDate == null) ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.EndDate.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1); OrderStatus? orderStatus = model.OrderStatusId > 0 ? (OrderStatus?)(model.OrderStatusId) : null; PaymentStatus? paymentStatus = model.PaymentStatusId > 0 ? (PaymentStatus?)(model.PaymentStatusId) : null; ShippingStatus?shippingStatus = model.ShippingStatusId > 0 ? (ShippingStatus?)(model.ShippingStatusId) : null; var filterByProductId = 0; var product = _productService.GetProductById(model.ProductId); //if (product != null && HasAccessToProduct(product)) // filterByProductId = model.ProductId; //load invoices var invoices = _invoiceService.SearchInvoices(storeId: model.StoreId, //vendorId: model.VendorId, productId: filterByProductId, warehouseId: model.WarehouseId, billingCountryId: model.BillingCountryId, paymentMethodSystemName: model.PaymentMethodSystemName, createdFromUtc: startDateValue, createdToUtc: endDateValue, os: orderStatus, ps: paymentStatus, ss: shippingStatus, billingEmail: model.CustomerEmail, orderNotes: model.OrderNotes, orderGuid: model.OrderGuid, pageIndex: command.Page - 1, pageSize: command.PageSize); foreach (var invoice in invoices) { var order = _orderService.GetOrderById(invoice.OrderId); invoice.OrderTotal = order.OrderTotal; } var gridModel = new DataSourceResult { Data = invoices.Select(x => { var store = _storeService.GetStoreById(x.StoreId); return(new InvoiceModel { Id = x.Id, StoreName = store != null ? store.Name : "Unknown", OrderTotal = _priceFormatter.FormatPrice(x.OrderTotal, true, false), OrderStatus = x.OrderStatus.GetLocalizedEnum(_localizationService, _workContext), PaymentStatus = x.PaymentStatus.GetLocalizedEnum(_localizationService, _workContext), ShippingStatus = x.ShippingStatus.GetLocalizedEnum(_localizationService, _workContext), // CustomerEmail = x.BillingAddress.Email, // CustomerFullName = string.Format("{0} {1}", x.BillingAddress.FirstName, x.BillingAddress.LastName), CreatedOn = _dateTimeHelper.ConvertToUserTime(x.CreatedOnUtc, DateTimeKind.Utc), Commission = x.Commission }); }), Total = invoices.TotalCount }; //summary report //currently we do not support productId and warehouseId parameters for this report var reportSummary = _orderReportService.GetOrderAverageReportLine( storeId: model.StoreId, vendorId: model.VendorId, billingCountryId: model.BillingCountryId, orderId: 0, paymentMethodSystemName: model.PaymentMethodSystemName, os: orderStatus, ps: paymentStatus, ss: shippingStatus, startTimeUtc: startDateValue, endTimeUtc: endDateValue, billingEmail: model.CustomerEmail, orderNotes: model.OrderNotes); var profit = _orderReportService.ProfitReport( storeId: model.StoreId, vendorId: model.VendorId, billingCountryId: model.BillingCountryId, paymentMethodSystemName: model.PaymentMethodSystemName, os: orderStatus, ps: paymentStatus, ss: shippingStatus, startTimeUtc: startDateValue, endTimeUtc: endDateValue, billingEmail: model.CustomerEmail, orderNotes: model.OrderNotes); var primaryStoreCurrency = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId); if (primaryStoreCurrency == null) { throw new Exception("Cannot load primary store currency"); } gridModel.ExtraData = new OrderAggreratorModel { aggregatorprofit = _priceFormatter.FormatPrice(profit, true, false), aggregatorshipping = _priceFormatter.FormatShippingPrice(reportSummary.SumShippingExclTax, true, primaryStoreCurrency, _workContext.WorkingLanguage, false), aggregatortax = _priceFormatter.FormatPrice(reportSummary.SumTax, true, false), aggregatortotal = _priceFormatter.FormatPrice(reportSummary.SumOrders, true, false) }; return(new JsonResult { Data = gridModel }); }
public ActionResult List(int?orderStatusId = null, int?paymentStatusId = null, int?shippingStatusId = null) { //if (!_permissionService.Authorize(StandardPermissionProvider.ManageOrders)) // return AccessDeniedView(); //if (_workContext.CurrentVendor != null) //{ var orders = _orderService.SearchOrders(); //} foreach (var order in orders) { decimal commission = new decimal(0); foreach (var item in order.OrderItems) { var productTemplates = _productTemplateService.GetAllProductTemplates(); foreach (var template in productTemplates) { if (template.Id == item.Product.ProductTemplateId) { } } } var invoice = new Invoice { OrderId = order.Id, Commission = order.OrderTotal * new decimal(0.15), StoreId = order.StoreId, IsCommissionPaid = false, CreatedOnUtc = DateTime.Now, PaymentStatus = order.PaymentStatus, ShippingStatus = order.ShippingStatus, BillingAddress = order.BillingAddress, OrderStatus = order.OrderStatus, ProductId = 0 }; if (_invoiceService.GetInvoicesByOrderId(order.Id) == null) { _invoiceService.InsertInvoice(invoice); } else { _invoiceService.UpdateInvoice(invoice); } } //order statuses var model = new InvoiceListModel(); model.AvailableOrderStatuses = OrderStatus.Pending.ToSelectList(false).ToList(); model.AvailableOrderStatuses.Insert(0, new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); if (orderStatusId.HasValue) { //pre-select value? var item = model.AvailableOrderStatuses.FirstOrDefault(x => x.Value == orderStatusId.Value.ToString()); if (item != null) { item.Selected = true; } } //payment statuses model.AvailablePaymentStatuses = PaymentStatus.Pending.ToSelectList(false).ToList(); model.AvailablePaymentStatuses.Insert(0, new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); if (paymentStatusId.HasValue) { //pre-select value? var item = model.AvailablePaymentStatuses.FirstOrDefault(x => x.Value == paymentStatusId.Value.ToString()); if (item != null) { item.Selected = true; } } //shipping statuses model.AvailableShippingStatuses = ShippingStatus.NotYetShipped.ToSelectList(false).ToList(); model.AvailableShippingStatuses.Insert(0, new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); if (shippingStatusId.HasValue) { //pre-select value? var item = model.AvailableShippingStatuses.FirstOrDefault(x => x.Value == shippingStatusId.Value.ToString()); if (item != null) { item.Selected = true; } } //stores model.AvailableStores.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); foreach (var s in _storeService.GetAllStores()) { model.AvailableStores.Add(new SelectListItem { Text = s.Name, Value = s.Id.ToString() }); } ////vendors //model.AvailableVendors.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); //foreach (var v in _vendorService.GetAllVendors(showHidden: true)) // model.AvailableVendors.Add(new SelectListItem { Text = v.Name, Value = v.Id.ToString() }); ////warehouses //model.AvailableWarehouses.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); //foreach (var w in _shippingService.GetAllWarehouses()) // model.AvailableWarehouses.Add(new SelectListItem { Text = w.Name, Value = w.Id.ToString() }); //payment methods model.AvailablePaymentMethods.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "" }); foreach (var pm in _paymentService.LoadAllPaymentMethods()) { model.AvailablePaymentMethods.Add(new SelectListItem { Text = pm.PluginDescriptor.FriendlyName, Value = pm.PluginDescriptor.SystemName }); } ////billing countries //foreach (var c in _countryService.GetAllCountriesForBilling(true)) //{ // model.AvailableCountries.Add(new SelectListItem { Text = c.Name, Value = c.Id.ToString() }); //} //model.AvailableCountries.Insert(0, new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); //a vendor should have access only to orders with his products model.IsLoggedInAsVendor = _workContext.CurrentVendor != null; return(View(model)); }