private List <SalesSummaryData> GetSeries(DateRange range) { range.CalculateDatesFromType(TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, HccApp.CurrentStore.Settings.TimeZone)); return(HccApp.OrderServices.Transactions.FindTotalTransactionsByDateRange(range.StartDate, range.EndDate, GetRangeFunction(range.RangeType))); }
public string GetPaymentsReport(int dateRange, int pageNumber, int pageSize) { var range = new DateRange { RangeType = (DateRangeType)dateRange }; range.CalculateDatesFromType(DateTime.Now); var aff = HccApp.ContactServices.Affiliates.FindByUserId(HccApp.CurrentCustomerId.ConvertTo <int>()); var totals = HccApp.ContactServices.Affiliates.GetAffiliateTotals(aff.Id, new AffiliateReportCriteria { StartDateUtc = range.StartDate, EndDateUtc = range.EndDate }, AffiliateRepository.TotalsReturnType.ReturnPayments); int total; var payments = GetPayments(aff, range.StartDate, range.EndDate, pageNumber, pageSize, out total); return (JsonConvert.SerializeObject(new AffiliatePaymentsViewModel { Payments = payments, TotalCount = totals.PaymentsCount, TotalAmount = totals.Commission.ToString("C") })); }
public string GetOrdersReport(int dateRange, int pageNumber, int pageSize) { var range = new DateRange { RangeType = (DateRangeType)dateRange }; range.CalculateDatesFromType(DateTime.Now); var aff = HccApp.ContactServices.Affiliates.FindByUserId(HccApp.CurrentCustomerId.ConvertTo <int>()); var totals = HccApp.ContactServices.Affiliates.GetAffiliateTotals(aff.Id, new AffiliateReportCriteria { StartDateUtc = range.StartDate, EndDateUtc = range.EndDate }, AffiliateRepository.TotalsReturnType.ReturnOrders); var totalRowCount = 0; var orders = GetOrders(aff, range.StartDate, range.EndDate, pageNumber, pageSize, ref totalRowCount); return (JsonConvert.SerializeObject(new AffiliateOrdersViewModel { Orders = orders, TotalCount = totals.OrdersCount, TotalAmount = totals.SalesAmount.ToString("C") })); }
public DateTime GetStartDateUtc(HotcakesApplication hccApp) { DateTime result; if (RangeType == DateRangeType.Custom) { var date = radStartDate.SelectedDate; result = (date ?? radStartDate.MinDate).ZeroOutTime(); } else { _range.RangeType = RangeType; ; _range.CalculateDatesFromType(DateHelper.ConvertUtcToStoreTime(hccApp)); result = _range.StartDate; } return(DateHelper.ConvertStoreTimeToUtc(hccApp, result)); }
public DateTime GetStartDateUtc(HotcakesApplication hccApp) { DateTime result; if (RangeType == DateRangeType.Custom) { var date = DateTime.Parse(radStartDate.Text.Trim()); result = date.ZeroOutTime(); } else { _range.RangeType = RangeType; ; _range.CalculateDatesFromType(DateHelper.ConvertUtcToStoreTime(hccApp)); result = _range.StartDate; } return(DateHelper.ConvertStoreTimeToUtc(hccApp, result)); }
public ActionResult Index() { var model = new AffiliateDashboardViewModel(); var aff = HccApp.ContactServices.Affiliates.FindByUserId(HccApp.CurrentCustomerId.ConvertTo <int>()); if (aff == null) { return(View((AffiliateDashboardViewModel)null)); } var affModel = new AffiliateViewModel(aff); LoadModel(affModel); FillRequiredFields(affModel); model.Affiliate = affModel; var range = new DateRange { RangeType = DefaultDateRange }; range.CalculateDatesFromType(DateTime.Now); var totals = HccApp.ContactServices.Affiliates.GetAffiliateTotals(aff.Id, new AffiliateReportCriteria { StartDateUtc = range.StartDate, EndDateUtc = range.EndDate }); var totalRowCount = 0; model.Orders = new AffiliateOrdersViewModel { Orders = GetOrders(aff, range.StartDate, range.EndDate, 1, 5, ref totalRowCount), TotalCount = totals.OrdersCount, TotalAmount = totals.SalesAmount.ToString("C") }; int totalPayments; model.Payments = new AffiliatePaymentsViewModel { Payments = GetPayments(aff, range.StartDate, range.EndDate, 1, 5, out totalPayments), TotalCount = totals.PaymentsCount, TotalAmount = totals.CommissionPaid.ToString("C") }; if (HccApp.CurrentStore.Settings.AffiliateDisplayChildren) { model.Affiliate.AllowReferral = true; var totalsReferrals = HccApp.ContactServices.Affiliates.GetTotalsByFilter(new AffiliateReportCriteria { ReferralAffiliateID = aff.AffiliateId, SearchBy = AffiliateReportCriteria.SearchType.AffiliateId, SearchText = null }, AffiliateRepository.TotalsReturnType.ReturnPayments); int totalReferals; model.Referrals = new AffiliateReferralsViewModel { Referrals = GetReferrals(aff, AffiliateReportCriteria.SearchType.AffiliateId, null, 1, 5, out totalReferals), TotalCount = totalReferals, TotalAmount = totalsReferrals.Commission.ToString("C") }; } //model.DefaultDateRange = (int)DefaultDateRange; model.UrlBuilder = new AffiliateUrlBuilderViewModel { AffiliateId = model.Affiliate.MyAffiliateId, Categories = GetCategoriesList(), RegistrationUrl = Url.RouteHccUrl(HccRoute.AffiliateRegistration) }; return(View(model)); }
private void AddWeekData(WeeklySummary result, DateRangeType weekRangeType) { var rangeData = new DateRange(); rangeData.RangeType = weekRangeType; rangeData.CalculateDatesFromType(DateHelper.ConvertUtcToStoreTime(_hccApp)); var totalCount = 0; var storeId = _hccApp.CurrentStore.Id; var data = _hccApp.OrderServices.Transactions .FindForReportByDateRange(rangeData.StartDate.ToUniversalTime(), rangeData.EndDate.ToUniversalTime(), storeId, int.MaxValue, 1, ref totalCount); decimal m = 0; decimal t = 0; decimal w = 0; decimal r = 0; decimal f = 0; decimal s = 0; decimal y = 0; foreach (var ot in data) { var timeStamp = DateHelper.ConvertUtcToStoreTime(_hccApp, ot.TimeStampUtc); switch (timeStamp.DayOfWeek) { case DayOfWeek.Monday: m += ot.AmountAppliedToOrder; break; case DayOfWeek.Tuesday: t += ot.AmountAppliedToOrder; break; case DayOfWeek.Wednesday: w += ot.AmountAppliedToOrder; break; case DayOfWeek.Thursday: r += ot.AmountAppliedToOrder; break; case DayOfWeek.Friday: f += ot.AmountAppliedToOrder; break; case DayOfWeek.Saturday: s += ot.AmountAppliedToOrder; break; case DayOfWeek.Sunday: y += ot.AmountAppliedToOrder; break; } } result.Monday = m; result.Tuesday = t; result.Wednesday = w; result.Thursday = r; result.Friday = f; result.Saturday = s; result.Sunday = y; }