Example #1
0
        private async Task ChangeCityAdministrationAsync(AnnualReport annualReport)
        {
            var oldCityAdministration = await _repositoryWrapper.CityAdministration.GetFirstOrDefaultAsync(
                predicate : c => c.CityId == annualReport.CityId && (c.EndDate == null || c.EndDate > DateTime.Now) && c.AdminTypeId == _cityAdminType.ID);

            if (oldCityAdministration != null && oldCityAdministration.UserId != annualReport.CityManagement.UserId)
            {
                var user = await _userManager.FindByIdAsync(oldCityAdministration.UserId);

                await _userManager.RemoveFromRoleAsync(user, _cityAdminType.AdminTypeName);

                oldCityAdministration.EndDate = DateTime.Now;
                _repositoryWrapper.CityAdministration.Update(oldCityAdministration);
            }
            if ((oldCityAdministration == null || oldCityAdministration.UserId != annualReport.CityManagement.UserId) && annualReport.CityManagement.UserId != null)
            {
                var user = await _userManager.FindByIdAsync(annualReport.CityManagement.UserId);

                await _userManager.AddToRoleAsync(user, _cityAdminType.AdminTypeName);

                await _repositoryWrapper.CityAdministration.CreateAsync(new CityAdministration
                {
                    CityId      = annualReport.CityId,
                    UserId      = annualReport.CityManagement.UserId,
                    AdminTypeId = _cityAdminType.ID,
                    StartDate   = DateTime.Now
                });
            }
            annualReport.CityManagement.CityAdminOldId = oldCityAdministration?.ID;
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get auth data

        this._authenticationData = GetAuthenticationDataAndCulture();

        // Get current year

        this._year = DateTime.Today.Year;

        string yearParameter = Request.QueryString["Year"];

        if (!string.IsNullOrEmpty(yearParameter))
        {
            this._year = Int32.Parse(yearParameter);  // will throw if non-numeric - don't matter for app
        }

        AnnualReport report = AnnualReport.Create(CurrentOrganization, this._year, FinancialAccountType.Result);

        LocalizeRoot(report.ReportLines);

        Response.ContentType = "application/json";

        Response.Output.WriteLine("{\"rows\": " + RecurseReport(report.ReportLines) + ", \"footer\": [" +
                                  WriteFooter(report.Totals) + "]}");

        Response.End();
    }
Example #3
0
    void RenderGroup(AnnualReport previousReport, AnnualReport currentReport)
    {
        var shareholderId = MyCompany.shareholder.Id;

        var previousList = previousReport.Groups;
        var currentList  = currentReport.Groups;

        RenderChanges(previousList, currentList, shareholderId, GroupRating, GroupRatingChange);
    }
Example #4
0
    void RenderHuman(AnnualReport previousReport, AnnualReport currentReport)
    {
        var shareholderId = Hero.shareholder.Id;

        var previousList = previousReport.People;
        var currentList  = currentReport.People;

        RenderChanges(previousList, currentList, shareholderId, ForbesRating, ForbesRatingChange);
    }
Example #5
0
        public JsonResult annualReport()
        {
            AnnualReport  annualReport        = new AnnualReport();
            List <string> annualReportDate    = new List <string>();
            List <string> annualReportDateUse = new List <string>();
            string        stroreN             = this.User.Identity.Name;

            using (GiftCardEntities db = new GiftCardEntities())
            {
                annualReportDate = db.GiftCards.Where(s => s.StoreID == stroreN).
                                   Select(s => s.GiftCardValid).ToList();
                annualReportDateUse = db.Receipts.Where(r => r.StoreId == stroreN).
                                      Select(s => s.DatePurchas).ToList();
            }
            //gift catd buy
            foreach (string date in annualReportDate)
            {
                if (date.Contains(DateTime.Now.AddYears(1).Year.ToString()))
                {
                    annualReport.CountA++;
                }
                if (date.Contains(DateTime.Now.AddYears(0).Year.ToString()))
                {
                    annualReport.CountB++;
                }
                if (date.Contains(DateTime.Now.AddYears(-1).Year.ToString()))
                {
                    annualReport.CountC++;
                }
            }

            //use
            foreach (string date in annualReportDateUse)
            {
                if (date.Contains(DateTime.Now.Year.ToString()))
                {
                    annualReport.UsegA++;
                }
                if (date.Contains(DateTime.Now.AddYears(-1).Year.ToString()))
                {
                    annualReport.UsegB++;
                }
                if (date.Contains(DateTime.Now.AddYears(-2).Year.ToString()))
                {
                    annualReport.UsegC++;
                }
            }

            return(new JsonResult {
                Data = annualReport, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Example #6
0
 public IActionResult CreateAnnualReport(AnnualReport annualReport)
 {
     if (!_cityAccessManager.HasAccess(annualReport.UserId, annualReport.CityId))
         return RedirectToAction("HandleError", "Error", new { code = 403 });
     try
     {
         var city = _repoWrapper.City
                 .FindByCondition(c => c.ID == annualReport.CityId)
                 .First();
         if (ModelState.IsValid)
         {
             var annualReportCheck = _repoWrapper.AnnualReports
                 .FindByCondition(ar => ar.CityId == annualReport.CityId && ar.Date.Year == annualReport.Date.Year)
                 .FirstOrDefault();
             if (annualReportCheck == null)
             {
                 _repoWrapper.AnnualReports.Create(annualReport);
                 _repoWrapper.Save();
                 ViewData["Message"] = $"Звіт станиці {city.Name} за {annualReport.Date.Year} рік створено!";
             }
             else
             {
                 ViewData["ErrorMessage"] = $"Звіт станиці {city.Name} за {annualReport.Date.Year} рік вже існує!";
             }
             return View("CreateEditAnnualReport");
         }
         else
         {
             var cityMembers = _repoWrapper.User
                 .FindByCondition(u => u.CityMembers.Any(cm => cm.City.ID == annualReport.CityId && cm.EndDate == null))
                 .Include(u => u.UserPlastDegrees);
             var annualReportViewModel = new AnnualReportViewModel
             {
                 Operation = AnnualReportOperation.Creating,
                 CityName = city.Name,
                 CityMembers = _annualReportVMCreator.GetCityMembers(cityMembers),
                 CityLegalStatusTypes = _annualReportVMCreator.GetCityLegalStatusTypes(),
                 AnnualReport = annualReport
             };
             ViewData["ErrorMessage"] = $"Звіт заповнений некоректно!";
             return View("CreateEditAnnualReport", annualReportViewModel);
         }
     }
     catch (Exception e)
     {
         _logger.LogError($"Exception: {e.Message}");
         return RedirectToAction("HandleError", "Error", new { code = 500 });
     }
 }
Example #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get current year

        this._year = DateTime.Today.Year;

        string yearParameter = Request.QueryString["Year"];

        if (!string.IsNullOrEmpty(yearParameter))
        {
            this._year = Int32.Parse(yearParameter);  // will throw if non-numeric - don't matter for app
        }

        AnnualReport report = AnnualReport.Create(CurrentOrganization, this._year, FinancialAccountType.Result);

        Response.ClearContent();
        Response.ClearHeaders();
        Response.ContentType = "text/plain";
        Response.AppendHeader("Content-Disposition",
                              "attachment;filename=" + CurrentOrganization.Name.Replace(" ", "") + "-" + Ledgers.ProfitLossStatement_DownloadFileName +
                              this._year.ToString(CultureInfo.InvariantCulture) + "-" + DateTime.Today.ToString("yyyyMMdd") + ".csv");

        if (this._year == DateTime.Today.Year)
        {
            Response.Output.WriteLine("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\"",
                                      Ledgers.ProfitLossStatement_AccountName,
                                      Ledgers.ProfitLossStatement_LastYear,
                                      Resources.Global.Global_Q1, Resources.Global.Global_Q2, Resources.Global.Global_Q3, Resources.Global.Global_Q4,
                                      Ledgers.ProfitLossStatement_Ytd);
        }
        else
        {
            Response.Output.WriteLine("\"{0}\",\"{1}\",\"{6}-{2}\",\"{6}-{3}\",\"{6}-{4}\",\"{6}-{5}\",\"{6}\"",
                                      Ledgers.ProfitLossStatement_AccountName, this._year - 1,
                                      Resources.Global.Global_Q1, Resources.Global.Global_Q2, Resources.Global.Global_Q3, Resources.Global.Global_Q4,
                                      this._year);
        }

        LocalizeRoot(report.ReportLines);

        RecurseCsvReport(report.ReportLines, string.Empty);

        Response.End();
    }
Example #8
0
 public IActionResult EditAnnualReport(AnnualReport annualReport)
 {
     try
     {
         var annualReportCheck = _repoWrapper.AnnualReports
             .FindByCondition(ar => ar.ID == annualReport.ID && ar.CityId == annualReport.CityId && ar.UserId == annualReport.UserId
             && ar.Status == AnnualReportStatus.Unconfirmed)
             .Include(ar => ar.City)
             .First();
         var userId = _userManager.GetUserId(User);
         if (!_cityAccessManager.HasAccess(userId, annualReport.CityId))
         {
             return RedirectToAction("HandleError", "Error", new { code = 403 });
         }
         if (ModelState.IsValid)
         {
             _repoWrapper.AnnualReports.Update(annualReport);
             _repoWrapper.Save();
             ViewData["Message"] = $"Звіт станиці {annualReportCheck.City.Name} за {annualReportCheck.Date.Year} рік відредаговано!";
             return View("CreateEditAnnualReport");
         }
         else
         {
             var cityMembers = _repoWrapper.User
                 .FindByCondition(u => u.CityMembers.Any(cm => cm.City.ID == annualReport.CityId && cm.EndDate == null))
                 .Include(u => u.UserPlastDegrees);
             var annualReportViewModel = new AnnualReportViewModel
             {
                 Operation = AnnualReportOperation.Editing,
                 CityName = annualReportCheck.City.Name,
                 CityMembers = _annualReportVMCreator.GetCityMembers(cityMembers),
                 CityLegalStatusTypes = _annualReportVMCreator.GetCityLegalStatusTypes(),
                 AnnualReport = annualReport
             };
             return View("CreateEditAnnualReport", annualReportViewModel);
         }
     }
     catch (Exception e)
     {
         _logger.LogError($"Exception: {e.Message}");
         return RedirectToAction("HandleError", "Error", new { code = 500 });
     }
 }
    protected override void Execute(List <GameEntity> entities)
    {
        var reportContainer = gameContext.GetEntities(GameMatcher.Reports)[0];

        var reports = reportContainer.reports.AnnualReports;

        int date = ScheduleUtils.GetCurrentDate(gameContext);

        AnnualReport report = new AnnualReport
        {
            Groups   = GetGroupList(),
            People   = GetPeopleList(),
            Products = GetProductList(),
            Date     = date
        };

        reports.Add(report);

        reportContainer.ReplaceReports(reports);
    }
Example #10
0
        private async Task ChangeCityLegalStatusAsync(AnnualReport annualReport)
        {
            var oldCityLegalStatus = await _repositoryWrapper.CityLegalStatuses.GetFirstOrDefaultAsync(
                predicate : c => c.CityId == annualReport.CityId && (c.DateFinish == null || c.DateFinish > DateTime.Now));

            if (oldCityLegalStatus != null && oldCityLegalStatus.LegalStatusType != annualReport.CityManagement.CityLegalStatusNew)
            {
                oldCityLegalStatus.DateFinish = DateTime.Now;
                _repositoryWrapper.CityLegalStatuses.Update(oldCityLegalStatus);
            }
            if (oldCityLegalStatus == null || oldCityLegalStatus.LegalStatusType != annualReport.CityManagement.CityLegalStatusNew)
            {
                await _repositoryWrapper.CityLegalStatuses.CreateAsync(new CityLegalStatus
                {
                    CityId          = annualReport.CityId,
                    LegalStatusType = annualReport.CityManagement.CityLegalStatusNew,
                    DateStart       = DateTime.Now
                });
            }
            annualReport.CityManagement.CityLegalStatusOldId = oldCityLegalStatus?.Id;
        }
Example #11
0
        public static List <AnnualReport> GetAnnualOverview(this UnitOfWork unit, int year, ModelFactory factory)
        {
            var query = unit.Projects.Get().OrderBy(x => x.Name)
                        .Select(x => new
            {
                project = x.Name,
                details = x.Tasks.Where(d => d.Day.Date.Year == year)
                          .GroupBy(d => d.Day.Date.Month)
                          .Select(w => new { month = w.Key, hours = w.Sum(d => d.Hours) })
                          .ToList()
            }).ToList();

            List <AnnualReport> list  = new List <AnnualReport>();
            AnnualReport        total = new AnnualReport {
                ProjectName = "T O T A L"
            };

            foreach (var q in query)
            {
                AnnualReport item = new AnnualReport {
                    ProjectName = q.project
                };
                foreach (var w in q.details)
                {
                    item.TotalHours  += w.hours;
                    total.TotalHours += w.hours;
                    item.MonthlyHours[w.month - 1]   = w.hours;
                    total.MonthlyHours[w.month - 1] += w.hours;
                }
                if (item.TotalHours > 0)
                {
                    list.Add(item);
                }
            }
            list.Add(total);
            return(list);
        }
Example #12
0
        public AnnualReport GetAnnualReport(string userId, int cityId, IEnumerable <User> cityMembers)
        {
            var membersStatistic = new MembersStatistic
            {
                NumberOfSeniorPlastynSupporters = cityMembers
                                                  .ToList()
                                                  .Where(cm => cm.UserPlastDegrees.Any(upd => upd.DateFinish == null &&
                                                                                       upd.UserPlastDegreeType == UserPlastDegreeType.SeniorPlastynSupporter))
                                                  .Count(),
                NumberOfSeniorPlastynMembers = cityMembers
                                               .ToList()
                                               .Where(cm => cm.UserPlastDegrees.Any(upd => upd.DateFinish == null &&
                                                                                    upd.UserPlastDegreeType == UserPlastDegreeType.SeniorPlastynMember))
                                               .Count(),
                NumberOfSeigneurSupporters = cityMembers
                                             .ToList()
                                             .Where(cm => cm.UserPlastDegrees.Any(upd => upd.DateFinish == null &&
                                                                                  upd.UserPlastDegreeType == UserPlastDegreeType.SeigneurSupporter))
                                             .Count(),
                NumberOfSeigneurMembers = cityMembers
                                          .ToList()
                                          .Where(cm => cm.UserPlastDegrees.Any(upd => upd.DateFinish == null &&
                                                                               upd.UserPlastDegreeType == UserPlastDegreeType.SeigneurMember))
                                          .Count(),
            };
            var annualReport = new AnnualReport
            {
                UserId           = userId,
                CityId           = cityId,
                MembersStatistic = membersStatistic,
                Status           = AnnualReportStatus.Unconfirmed,
                Date             = DateTime.Now
            };

            return(annualReport);
        }
Example #13
0
 public AnnualReportPdf(AnnualReport annualReport, IPdfSettings settings) : base(settings)
 {
     _annualReport = annualReport;
 }