public InvoiceAdministrationModel GetInvoiceAdministrationDetail(InvoiceFilterModel filter)
        {
            InvoiceAdministrationModel model = new InvoiceAdministrationModel(filter);

            if (filter == null)
            {
                filter      = new InvoiceFilterModel();
                filter.Size = 1;
            }

            var invoices = GetInvoices(filter);

            if (invoices != null && invoices.Count > 0)
            {
                //falls back to first invoice if current page is off the end
                var currentId = GetCurrentInvoiceId(filter, invoices);

                model.InvoiceList    = invoices.Select(i => i.Id).ToPagedList(filter.Page, filter.Size);
                model.CurrentInvoice = Mapper.Map <Data.Graph.Invoice, InvoiceModel>(InvoiceRepository.GetInvoice(currentId));
                model.Filter         = filter;

                if (!string.IsNullOrEmpty(model.CurrentInvoice.StockNumber))
                {
                    var history = InvoiceRepository.GetInvoiceHistory(model.CurrentInvoice.StockNumber);
                    model.CurrentInvoice.History = Mapper.Map <IList <Data.Graph.StockNumberHistory>, List <HistoryModel> >(history);
                }
            }

            return(model);
        }
        private IList <InvoiceViewModel> GetInvoices(InvoiceFilterModel filter)
        {
            var cacheKey = "invoice-admin";

            var invoices = HttpRuntime.Cache[cacheKey] as IList <InvoiceViewModel>;

            if (invoices == null || invoices.Count == 0 || filter.DoEvaluate)
            {
                // load from database
                Logger.Info("Loading invoice administration from database");
                var query  = Mapper.Map <InvoiceFilterModel, Data.Query.InvoiceQuery>(filter);
                var result = InvoiceRepository.GetInvoices(query);
                invoices = Mapper.Map <IList <Data.Graph.InvoiceView>, IList <InvoiceViewModel> >(result);
                HttpRuntime.Cache.Insert(cacheKey, invoices, null, Cache.NoAbsoluteExpiration, TimeSpan.FromHours(1.0));
            }
            else
            {
                Logger.Info("Returning invoice administration from cache");
            }

            // load from cache unless told not to
            filter.DoEvaluate = false;

            return(invoices);
        }
 public static string GetGridData(string sessionKey, string cond, out string order)
 {
     //cond = cond == string.Empty ? "" : " AND ";
     //cond +=  CatSalestaffContract.Columns[(int)CatSalestaffColumns.ID] + " = 1 ";
     cond  = InvoiceFilterModel.getFilterCond(cond, sessionKey);
     order = "OrderNum DESC, Id DESC";
     return(cond);
 }
Beispiel #4
0
 public static string GetComboboxData(string sessionKey, out string columns, string cond, out string order)
 {
     //cond = cond == string.Empty ? "" : cond + " AND ";
     //cond += cond + CatSalestaffContract.Columns[(int)CatSalestaffColumns.ID] + " = 1 ";
     cond    = InvoiceFilterModel.getFilterCond(cond, sessionKey);
     columns = "ID, Code";
     order   = "OrderNum DESC";
     return(cond);
 }
        public void InvoiceServiceSetup()
        {
            service = WindsorPersistenceFixture.Container.Resolve <InvoiceAdministrationService>();

            filter                   = new InvoiceFilterModel();
            filter.AccountName       = "DOBBS FORD AT MT. MORIAH";
            filter.ReceivedDateStart = DateTime.Parse("12/7/2011");
            filter.ReceivedDateEnd   = DateTime.Parse("12/10/2011");
        }
        public ReturnRefundFilterView(InvoiceFilterModel filter)
        {
            InitializeComponent();
            NavigationPage.SetHasNavigationBar(this, false);

            this.BindingContext           = viewModel = new ReturnFilterViewModel(filter);
            viewModel.isFilterOneSelected = true;
            lstView.ItemTapped           += LstView_ItemTapped;
            timeTypePicker.SelectedItem   = Application.Current.Properties["TimePicker"];
            orderTypePicker.SelectedItem  = Application.Current.Properties["ordertypepicker"];

            timeTypePicker.SelectedIndexChanged  += TimeTypePicker_SelectedIndexChanged;
            orderTypePicker.SelectedIndexChanged += OrderTypePicker_SelectedIndexChanged;
        }
        public async Task <List <InvoiceModel> > Filter(InvoiceFilterModel invoiceFilterModel)
        {
            var locale   = CultureInfo.CurrentUICulture.Name;
            var memberId = User.Identity.Name.ToUpper().Trim();
            var invoices =
                await
                _invoiceProvider.Filter(new GetInvoicesByFilter
            {
                InvoiceFilterModel = invoiceFilterModel,
                MemberId           = memberId,
                Locale             = locale
            });

            return(invoices);
        }
        private int GetCurrentInvoiceId(InvoiceFilterModel filter, IList <InvoiceViewModel> invoices)
        {
            //fall back to first invoice if current page is off the end
            int currentId;

            if (filter.Page - 1 >= invoices.Count)
            {
                currentId   = invoices[0].Id;
                filter.Page = 1;
            }
            else
            {
                currentId = invoices[filter.Page - 1].Id;
            }
            return(currentId);
        }
        // TODO: test?
        public ActionResult InvoiceDetail(InvoiceFilterModel filter)
        {
            var detail = AdministrationServices.GetInvoiceAdministrationDetail(filter);

            ViewBag.Filter    = "InvoiceDetail";
            ViewBag.Locations = LocationServices.GetLocationLookup(true, filter.LocationId);
            ViewBag.Paid      = LookupServices.GetPaidOptions(filter.HasBeenPaid, true);

            if (detail.InvoiceList.Count == 0)
            {
                return(View("InvoiceDetailNoData", detail));
            }
            else
            {
                return(View("InvoiceDetail", detail));
            }
        }
        // TODO: test?
        public ActionResult InvoiceListing(InvoiceFilterModel filter)
        {
            var listing = AdministrationServices.GetInvoiceListing(filter);

            ViewBag.Filter    = "InvoiceListing";
            ViewBag.Locations = LocationServices.GetLocationLookup(true, filter.LocationId);
            ViewBag.Paid      = LookupServices.GetPaidOptions(filter.HasBeenPaid, true);
            ViewBag.Size      = LookupServices.GetSizeOptions(filter.Size);

            if (listing.InvoiceList.Count == 0)
            {
                return(View("InvoiceListingNoData", listing));
            }
            else
            {
                return(View("InvoiceListing", listing));
            }
        }
Beispiel #11
0
 public RefundReturnViewModel()
 {
     InvoiceFilter = new InvoiceFilterModel()
     {
         Amount         = "",
         ArticleNo      = "",
         CurrentPage    = "1",
         FranchiseId    = Application.Current.Properties["OtherId"].ToString(),
         FromDate       = "",
         SearchBy       = "",
         SortDirection  = "",
         PageSize       = "50",
         SortExpression = "FranchiseSellId",
         Status         = "",
         ToDate         = ""
     };
     IAllDataServices_data = new AllDataServices();
     InvoiceDataList       = new ObservableCollection <InvoiceDataModel>();
 }
        public ReturnFilterViewModel(InvoiceFilterModel filter)
        {
            FromDate    = ToDate = System.DateTime.Now;
            MinFromDate = MinToDate = System.DateTime.Now.AddYears(-5);


            if (filter == null)
            {
                filterModel = new InvoiceFilterModel()
                {
                    Amount         = "",
                    ArticleNo      = "",
                    CurrentPage    = "1",
                    FranchiseId    = Application.Current.Properties["OtherId"].ToString(),
                    FromDate       = "",
                    SearchBy       = "",
                    SortDirection  = "",
                    PageSize       = "",
                    SortExpression = "FranchiseSellId",
                    Status         = "",
                    ToDate         = ""
                };
            }
            else
            {
                filterModel = filter;
            }
            OrderTypes = new ObservableCollection <string>()
            {
                "RETURNED", "REFUNDED", "PARTIAL REFUNDED", "PARTIAL RETURNED", "SOLD"
            };
            TimeOptions = new ObservableCollection <string>()
            {
                "Last 10 Days", "Last 30 Days", "Last 6 Months", System.DateTime.Today.Year.ToString(), (System.DateTime.Today.Year - 1).ToString(), "Custom"
            };
            FilterOptions = new ObservableCollection <string>
            {
                "Article No.", "Amount", "Time", "Status"
            };
            isCustomDate = false;
        }
        public InvoiceListingModel GetInvoiceListing(InvoiceFilterModel filter)
        {
            if (filter == null)
            {
                filter = new InvoiceFilterModel();
            }

            var invoices = GetInvoices(filter);

            InvoiceListingModel model = new InvoiceListingModel();

            model.Filter      = filter;
            model.InvoiceList = invoices.ToPagedList(filter.Page, filter.Size);

            for (int i = 0; i < model.InvoiceList.Count; i++)
            {
                model.InvoiceList[i].RowId = ((filter.Page - 1) * filter.Size) + i + 1;
            }

            return(model);
        }
        public static RouteValueDictionary GenerateInvoiceRoute(this InvoiceFilterModel model, int?page = null, int?size = null)
        {
            var receiveDateString = string.Empty;

            if (model.ReceivedDateStart.HasValue)
            {
                receiveDateString = model.ReceivedDateStart.Value.ToShortDateString();
            }

            return(new RouteValueDictionary()
            {
                { "Page", (page.HasValue) ? page.ToString() : model.Page.ToString() },
                { "Size", (size.HasValue) ? size.Value.ToString() : model.Size.ToString() },
                { "ReceivedDateStart", receiveDateString },
                { "ReceivedDateEnd", model.ReceivedDateEnd.Value.ToShortDateString() },
                { "LocationId", model.LocationId.Value.ToString() },
                { "AccountName", model.AccountName },
                { "ExcludeZeroTotal", model.ExcludeZeroTotal.ToString() },
                { "HasBeenPaid", model.HasBeenPaid },
                { "DoEvaluate", model.DoEvaluate.ToString() }
            });
        }