Ejemplo n.º 1
0
 /// <summary>
 /// Handles refreshing after adding.
 /// </summary>
 void HandleContributionAddMessage(MessagingService obj, Contribution contribution)
 {
     State = LayoutState.Loading;
     Contributions.Add(contribution);
     Contributions = new ObservableCollection <Contribution>(Contributions.OrderByDescending(x => x.StartDate).ToList());
     State         = LayoutState.None;
 }
Ejemplo n.º 2
0
 public void Clear()
 {
     Contributions.Clear();
     Winners.Clear();
     TotalChips = 0;
     Cap        = 0;
 }
Ejemplo n.º 3
0
 public IUser GetOrCreateUserWithContribution(string username, Contributions contribution)
 {
     IUser user = GetUser(username);
     if(user == null)
     {
         user = CreateAnonymousUser();
         user.Name = username;
     }
     user.AddContribution(contribution);
     userRepository.UpdateUser(user);
     return user;
 }
Ejemplo n.º 4
0
        public void AddChips(Player contributedPlayer, decimal chips)
        {
            decimal currentSum = 0;

            if (Contributions.ContainsKey(contributedPlayer))
            {
                currentSum = Contributions[contributedPlayer];
            }
            currentSum += chips;
            TotalChips += chips;
            Contributions.Add(contributedPlayer, currentSum);
        }
Ejemplo n.º 5
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            // This is possible during design time load
            if (!(value is Contributions))
            {
                return(String.Empty);
            }

            Contributions info = value as Contributions;

            return(String.Format("{0} {1}%", info.ExchangeName, info.Value));
        }
Ejemplo n.º 6
0
        public void Add(Contribution contr, double res)
        {
            var cont = Contributions.Keys.FirstOrDefault(f => f.Name.Equals(contr.Name));

            if (cont == null)
            {
                Contributions.Add(contr, res);
            }
            else
            {
                Contributions[cont] += res;
            }
        }
Ejemplo n.º 7
0
 public IEnumerable<IUser> CreateUsersInBatch(IEnumerable<string> names, Contributions contribution, Sources source)
 {
     var newUsers =
         names.Where(name => !DoesUserExist(name)).Select(
             name => new User(name, userRepository.NonUserGeneratedPassword, string.Empty));
     Parallel.ForEach(newUsers, user =>
                                    {
                                        user.Source = source;
                                        user.AddContribution(contribution);
                                    });
     userRepository.AddUsers(newUsers);
     return newUsers;
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Handles refreshing after updating.
        /// </summary>
        void HandleContributionUpdateMessage(MessagingService obj, Contribution contribution)
        {
            var prev = Contributions.FirstOrDefault(x => x.ContributionId == contribution.ContributionId);

            if (prev != null)
            {
                State = LayoutState.Loading;
                Contributions.Remove(prev);
                Contributions.Add(contribution);
                Contributions = new ObservableCollection <Contribution>(Contributions.OrderByDescending(x => x.StartDate).ToList());
                State         = LayoutState.None;
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Gets a paginated list of contributions.
        /// </summary>
        /// <param name="offset">The page skip.</param>
        /// <param name="limit">The page take.</param>
        /// <param name="cancellationToken">An optional cancellation token.</param>
        /// <returns>A <see cref="Contributions"/> object.</returns>
        public async Task <Contributions> GetContributionsAsync(
            int offset,
            int limit,
            CancellationToken cancellationToken = default)
        {
            Contributions result = await this.GetAsync <Contributions>(
                $"{ContributionEndpoint}/{offset}/{limit}",
                true,
                null,
                cancellationToken);

            result.EvaluatePagination(limit);
            return(result);
        }
Ejemplo n.º 10
0
        async Task RefreshContributions()
        {
            Contributions.Clear();
            contributions.Clear();

            var contributionsList = await MvpApiService.GetContributionsAsync(0, pageSize).ConfigureAwait(false);

            if (contributionsList == null)
            {
                return;
            }

            Contributions = contributionsList.Contributions;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Loads more contributions when scrolled to the bottom.
        /// </summary>
        async Task LoadMore()
        {
            if (IsLoadingMore)
            {
                return;
            }

            if (!await VerifyInternetConnection())
            {
                return;
            }

            try
            {
                IsLoadingMore = true;

                var contributionsList = await MvpApiService.GetContributionsAsync(Contributions.Count, pageSize).ConfigureAwait(false);

                if (contributionsList == null)
                {
                    await DialogService.AlertAsync(Translations.error_couldntloadmorecontributions, Translations.error_title, Translations.ok).ConfigureAwait(false);

                    return;
                }

                foreach (var item in contributionsList.Contributions.OrderByDescending(x => x.StartDate))
                {
                    Contributions.Add(item);
                }

                AnalyticsService.Track("More Contributions Loaded");

                // If we've reached the end, change the threshold.
                if (!contributionsList.Contributions.Any())
                {
                    ItemThreshold = -1;
                    return;
                }
            }
            catch (Exception ex)
            {
                AnalyticsService.Report(ex);
                await DialogService.AlertAsync(Translations.error_couldntloadmorecontributions, Translations.error_title, Translations.ok).ConfigureAwait(false);
            }
            finally
            {
                IsLoadingMore = false;
            }
        }
Ejemplo n.º 12
0
        async Task RefreshContributions()
        {
            if (Connectivity.NetworkAccess == NetworkAccess.Internet)
            {
                Contributions.Clear();

                var contributionsList = await _mvpApiService.GetContributionsAsync(0, _pageSize, true).ConfigureAwait(false);

                if (contributionsList != null)
                {
                    _contributions.AddRange(contributionsList.Contributions);
                    Contributions = _contributions.ToGroupedContributions();
                }
            }
        }
Ejemplo n.º 13
0
 public void LoadContributions()
 {
     Contributions.Clear();
     if (LoggedUserID.actualGroupModel != null)
     {
         GroupModel group = LoggedUserID.actualGroupModel;
         //Get All ContributionsByGroupId
         var contr = contributionRepository.GetAllContributionsInGroupById(group.Id);
         foreach (var item in contr)
         {
             item.Comments = commentRepository.GetAllCommentsOfContributionById(item.Id);
             Contributions.Add(item);
         }
     }
 }
Ejemplo n.º 14
0
        public void RemoveChips(Player player, decimal chips)
        {
            if (!Contributions.ContainsKey(player))
            {
                return;
            }
            decimal currentSum = Contributions[player];

            if (chips <= currentSum)
            {
                currentSum -= chips;
                TotalChips -= chips;
                Contributions.Add(player, currentSum);
            }
            else
            {
                // TODO: throw Exception, maybe?
                TotalChips -= currentSum;
                Contributions.Add(player, 0);
            }
        }
Ejemplo n.º 15
0
 public bool IsUserInvolvedAs(IUser user, Contributions contribution)
 {
     return involvements.Any(i => i.Key.Equals(user) && i.Value.Equals(contribution));
 }
Ejemplo n.º 16
0
 public void InvolveUsers(IEnumerable<IUser>users, Contributions contribution)
 {
     if(users.Any(u=>!u.IsContributingAs(contribution)))
     {
         throw new ArgumentException(String.Format("At least one use is not a {0}.", contribution), "users");
     }
     lock (involvements)
     {
         involvements = involvements.Union(
                 users.Where(u => !GetInvolvedUsersForContribution(contribution).Contains(u))
                 .Select(u => new KeyValuePair<IUser, Contributions>(u, contribution))
             ).ToList();
     }
 }
Ejemplo n.º 17
0
 public void InvolveUser(IUser user, Contributions contribution)
 {
     if(!user.IsContributingAs(contribution))
     {
         throw new ArgumentException(String.Format("User {0} is not a {1}.", user, contribution), "contribution");
     }
     lock (involvements)
     {
         if (!IsUserInvolvedAs(user, contribution))
         {
             involvements.Add(new KeyValuePair<IUser, Contributions>(user, contribution));
         }
     }
 }
Ejemplo n.º 18
0
 public IEnumerable<IUser> GetInvolvedUsersForContribution(Contributions contribution)
 {
     return involvements
         .Where(i => i.Value.Equals(contribution))
         .Select(i => i.Key);
 }
Ejemplo n.º 19
0
 public void DisInvolveUser(IUser user, Contributions contribution)
 {
     lock (involvements)
     {
         involvements = involvements.Where(i => !(i.Key.Equals(user) && i.Value.Equals(contribution))).ToList();
     }
 }
Ejemplo n.º 20
0
        public ActionResult GetMonthlyContributionSummary(string start, string end)
        {
            var    user       = UserManager.Users.Where(x => x.UserName == User.Identity.Name).First();
            string SchemeName = PensionSetup.GetSchemeNameAsync(user.SponsorNumber);

            ContributionSummary_Service contributionService = new ContributionSummary_Service();

            contributionService.Url = "http://" + PensionSetup.ServerName + ":" + PensionSetup.ServerPort + "/" + PensionSetup.ServerInstance + "/WS/" + SchemeName + "/Page/ContributionSummary";
            contributionService.UseDefaultCredentials = false;
            contributionService.Credentials           = new NetworkCredential(PensionSetup.SoapUsername, PensionSetup.SoapPassword);

            List <ContributionSummary_Filter> filterArray = new List <ContributionSummary_Filter>();
            ContributionSummary_Filter        nameFilter  = new ContributionSummary_Filter();

            string MemberNumber = user.MemberNumber;

            nameFilter.Field    = ContributionSummary_Fields.Vendor_No;
            nameFilter.Criteria = MemberNumber;

            filterArray.Add(nameFilter);

            ContributionSummary[] contribution = contributionService.ReadMultiple(filterArray.ToArray(), null, 0);

            var contributionStartDate = contribution.Where(m => m.Vendor_No == MemberNumber).Select(d => d.Min_Cont_Date).First();
            var contributionEndDate   = contribution.Where(m => m.Vendor_No == MemberNumber).First().Max_Cont_Date;

            DateTime startDate;
            DateTime endDate;

            if (start == "" || end == "")
            {
                startDate = contributionStartDate;
                endDate   = contributionEndDate;
            }
            else
            {
                startDate = DateTime.ParseExact(start, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                endDate   = DateTime.ParseExact(end, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            }

            startDate = startDate.Date;
            endDate   = endDate.Date;

            var startDateObj = new DateTime(startDate.Year, startDate.Month, startDate.Day);
            var endDateObj   = new DateTime(endDate.Year, endDate.Month, endDate.Day);

            //var contributionStartDateObj = new DateTime(contributionStartDate.Year, contributionStartDate.Month, contributionStartDate.Day);
            //var contributionEndDateObj = new DateTime(contributionEndDate.Year, contributionEndDate.Month, contributionEndDate.Day);

            //if (startDateObj < contributionStartDateObj)
            //{
            //    startDateObj = contributionStartDateObj;
            //}

            //if (endDateObj < contributionEndDate)
            //{
            //    endDateObj = contributionEndDateObj;
            //}

            decimal result = 0;
            decimal unregEmployeeAmount = 0;
            decimal regEmployeeAmount   = 0;

            decimal unregEmployerAmount = 0;
            decimal regEmployerAmount   = 0;

            decimal regEmployeeAdditionalAmount = 0;
            decimal regEmployerAdditionalAmount = 0;

            decimal unregEmployeeAdditionalAmount = 0;
            decimal unregEmployerAdditionalAmount = 0;

            decimal Pre90EEAmount = 0;
            decimal Pre90ERAmount = 0;

            List <Contributions> monthlyContributionArray = new List <Contributions>();

            DateTime curDateObj = startDateObj;

            while (startDateObj <= endDateObj)
            {
                var currentYear  = startDateObj.Year;
                var currentMonth = startDateObj.Month;

                //Registered Employee Contribution
                result = contribution.Where(r => (int)r.Contribution_Type == 1 &&
                                            (int)r.Exemption_Type == 1 &&
                                            (int)r.Transaction_Type == 1 &&
                                            r.Contribution_Period.Year == currentYear &&
                                            r.Contribution_Period.Month == currentMonth)
                         .Select(r => r.Amount_LCY)
                         .Sum();

                if (result == 0)
                {
                    regEmployeeAmount = 0;
                }
                else
                {
                    regEmployeeAmount = result;
                }

                //Unregistered Employee Contribution
                result = contribution.Where(r => (int)r.Contribution_Type == 5 &&
                                            (int)r.Transaction_Type == 1 &&
                                            (int)r.Exemption_Type == 2 &&
                                            r.Contribution_Period.Year == currentYear &&
                                            r.Contribution_Period.Month == currentMonth)
                         .Select(x => x.Amount_LCY)
                         .Sum();

                if (result == 0)
                {
                    unregEmployeeAmount = 0;
                }
                else
                {
                    unregEmployeeAmount = result;
                }

                var totalEmployeeContribution = regEmployeeAmount + unregEmployeeAmount;

                //Registered Employer Contribution
                result = contribution.Where(c => (int)c.Contribution_Type == 2 &&
                                            (int)c.Transaction_Type == 1 &&
                                            (int)c.Exemption_Type == 1 &&
                                            c.Contribution_Period.Year == currentYear &&
                                            c.Contribution_Period.Month == currentMonth).Select(x => x.Amount_LCY).Sum();

                if (result == 0)
                {
                    regEmployerAmount = 0;
                }
                else
                {
                    regEmployerAmount = result;
                }

                //Unregistered Employer Contribution
                result = contribution.Where(c => (int)c.Contribution_Type == 6 &&
                                            (int)c.Transaction_Type == 1 &&
                                            (int)c.Exemption_Type == 2 &&
                                            c.Contribution_Period.Year == currentYear &&
                                            c.Contribution_Period.Month == currentMonth)
                         .Select(x => x.Amount_LCY)
                         .Sum();

                if (result == 0)
                {
                    unregEmployerAmount = 0;
                }
                else
                {
                    unregEmployerAmount = result;
                }

                var totalEmployerContribution = regEmployerAmount + unregEmployerAmount;

                //Registered Employee Additional Contribution
                result = contribution.Where(c => (int)c.Contribution_Type == 4 &&
                                            (int)c.Transaction_Type == 1 &&
                                            (int)c.Exemption_Type == 1 &&
                                            c.Contribution_Period.Year == currentYear &&
                                            c.Contribution_Period.Month == currentMonth)
                         .Select(x => x.Amount_LCY)
                         .Sum();

                if (result == 0)
                {
                    regEmployeeAdditionalAmount = 0;
                }
                else
                {
                    regEmployeeAdditionalAmount = result;
                }

                //Unregistered Employee Additional Contribution
                result = contribution.Where(c => (int)c.Contribution_Type == 10 &&
                                            (int)c.Transaction_Type == 1 &&
                                            (int)c.Exemption_Type == 2 &&
                                            c.Contribution_Period.Year == currentYear &&
                                            c.Contribution_Period.Month == currentMonth)
                         .Select(x => x.Amount_LCY)
                         .Sum();

                if (result == 0)
                {
                    unregEmployeeAdditionalAmount = 0;
                }
                else
                {
                    unregEmployeeAdditionalAmount = result;
                }

                var totalAdditionalEmployeeContribution = regEmployeeAdditionalAmount + unregEmployeeAdditionalAmount;

                //Registered Employer Additional Contribution
                result = contribution.Where(c => (int)c.Contribution_Type == 3 &&
                                            (int)c.Transaction_Type == 1 &&
                                            (int)c.Exemption_Type == 1 &&
                                            c.Contribution_Period.Year == currentYear &&
                                            c.Contribution_Period.Month == currentMonth)
                         .Select(x => x.Amount_LCY)
                         .Sum();

                if (result == 0)
                {
                    regEmployerAdditionalAmount = 0;
                }
                else
                {
                    regEmployerAdditionalAmount = result;
                }

                //Unregistered Employer Additional Contribution
                result = contribution.Where(c => (int)c.Contribution_Type == 11 &&
                                            (int)c.Transaction_Type == 1 &&
                                            (int)c.Exemption_Type == 2 &&
                                            c.Contribution_Period.Year == currentYear &&
                                            c.Contribution_Period.Month == currentMonth)
                         .Select(x => x.Amount_LCY)
                         .Sum();

                if (result == 0)
                {
                    unregEmployerAdditionalAmount = 0;
                }
                else
                {
                    unregEmployerAdditionalAmount = result;
                }

                //PRE 90 EE
                result = contribution.Where(c => (int)c.Contribution_Type == 12 &&
                                            (int)c.Transaction_Type == 1 &&
                                            (int)c.Exemption_Type == 2 &&
                                            c.Contribution_Period.Year == currentYear &&
                                            c.Contribution_Period.Month == currentMonth)
                         .Select(x => x.Amount_LCY)
                         .Sum();

                if (result == 0)
                {
                    Pre90EEAmount = 0;
                }
                else
                {
                    Pre90EEAmount = result;
                }

                //PRE 90 ER
                result = contribution.Where(c => (int)c.Contribution_Type == 13 &&
                                            (int)c.Transaction_Type == 1 &&
                                            (int)c.Exemption_Type == 2 &&
                                            c.Contribution_Period.Year == currentYear &&
                                            c.Contribution_Period.Month == currentMonth)
                         .Select(x => x.Amount_LCY)
                         .Sum();

                if (result == 0)
                {
                    Pre90ERAmount = 0;
                }
                else
                {
                    Pre90ERAmount = result;
                }


                var totalAdditionalEmployerContribution = regEmployerAdditionalAmount + unregEmployerAdditionalAmount;
                var avc        = totalAdditionalEmployeeContribution + totalAdditionalEmployerContribution;
                var totalPRE90 = Pre90EEAmount + Pre90ERAmount;

                var totalContribution = totalEmployeeContribution + totalEmployerContribution + totalAdditionalEmployeeContribution + totalAdditionalEmployerContribution + totalPRE90;

                var arr = new Contributions
                {
                    REG_EMPLOYEE_CONTRIBUTION   = System.Math.Abs(regEmployeeAmount),
                    UNREG_EMPLOYEE_CONTRIBUTION = System.Math.Abs(unregEmployeeAmount),
                    ER  = System.Math.Abs(totalEmployeeContribution),
                    EE  = System.Math.Abs(totalEmployerContribution),
                    AVC = System.Math.Abs(avc),
                    REG_EMPLOYER_CONTRIBUTION   = System.Math.Abs(regEmployerAmount),
                    UNREG_EMPLOYER_CONTRIBUTION = System.Math.Abs(unregEmployerAmount),

                    REG_EMPLOYEE_ADDITIONAL_CONTRIBUTION   = System.Math.Abs(regEmployeeAdditionalAmount),
                    UNREG_EMPLOYEE_ADDITIONAL_CONTRIBUTION = System.Math.Abs(unregEmployeeAdditionalAmount),

                    REG_EMPLOYER_ADDITIONAL_CONTRIBUTION   = System.Math.Abs(regEmployerAdditionalAmount),
                    UNREG_EMPLOYER_ADDITIONAL_CONTRIBUTION = System.Math.Abs(unregEmployerAdditionalAmount),
                    REG_AVC   = System.Math.Abs(regEmployerAdditionalAmount + regEmployeeAdditionalAmount),
                    UNREG_AVC = System.Math.Abs(unregEmployerAdditionalAmount + unregEmployeeAdditionalAmount),

                    TOTAL_PRE_90 = System.Math.Abs(totalPRE90),
                    PRE_90_EE    = System.Math.Abs(Pre90EEAmount),
                    PRE_90_ER    = System.Math.Abs(Pre90ERAmount),

                    FMT_TOTAL_EMPLOYEE_CONTRIBUTION = System.Math.Abs(totalEmployeeContribution),
                    FMT_TOTAL_EMPLOYER_CONTRIBUTION = System.Math.Abs(totalEmployerContribution),
                    FMT_AVC = System.Math.Abs(avc),

                    FMT_TOTAL_CONTRIBUTION = System.Math.Abs(totalContribution),
                    DATE = curDateObj
                };

                monthlyContributionArray.Add(arr);

                curDateObj   = curDateObj.AddMonths(1);
                startDateObj = curDateObj;
            }


            return(Json(monthlyContributionArray, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 21
0
    private static Contributions instantiate(DataSet ds)
    {
        Contributions c = new Contributions();

        c.Id = Convert.ToInt16(ds.Tables[0].Rows[0]["id"]);
        c.UserId = Convert.ToInt16(ds.Tables[0].Rows[0]["user_id"]);
        c.CauseId = Convert.ToInt16(ds.Tables[0].Rows[0]["cause_id"]);
        c.Contribution = ds.Tables[0].Rows[0]["contribute"].ToString();
        c.Date = Convert.ToDateTime(ds.Tables[0].Rows[0]["date"]);

        return c;
    }
Ejemplo n.º 22
0
 public bool IsContributingAs(Contributions contribution)
 {
     return contributions.Contains(contribution);
 }
Ejemplo n.º 23
0
        public IActionResult OnGetSIReport(int payrunId)
        {
            Payrun_Dto payrun = ObjectMapper.Map <Payrun, Payrun_Dto>(PayrunAppService.Repository.WithDetails().SingleOrDefault(x => x.Id == payrunId));
            List <SIContributionCategory_Dto> SIContributionCategories = ObjectMapper.Map <List <SIContributionCategory>, List <SIContributionCategory_Dto> >(SocialInsuranceAppService.Repository.WithDetails().First().ContributionCategories.ToList());

            if (payrun != null)
            {
                List <PayrunDetail_Dto> payrunDetails = payrun.PayrunDetails.ToList();
                List <dynamic>          dynamicDS     = new List <dynamic>();

                for (int i = 0; i < payrunDetails.Count; i++)
                {
                    PayrunDetail_Dto curDetail = payrunDetails[i];

                    if (curDetail.Employee.SIType == null || curDetail.Employee.SIType.Value != "Eligible")
                    {
                        continue;
                    }
                    SocialInsuranceReport_Dto employeeSIReport = GetSIReport(curDetail);

                    dynamic siDSRow = new ExpandoObject();
                    siDSRow.payrunId             = employeeSIReport.PayrunId;
                    siDSRow.sNo                  = i + 1;
                    siDSRow.getEmpName           = employeeSIReport.Employee.Name;
                    siDSRow.getEmpIdentityNumber = employeeSIReport.EmpID;
                    siDSRow.getEmpNationality    = employeeSIReport.Employee.Nationality.Value;
                    siDSRow.getEmpSIID           = employeeSIReport.EmpSIId;
                    siDSRow.getBasicSalary       = "" + employeeSIReport.BasicSalary.ToString("N2");

                    foreach (PayrunAllowanceSummary_Dto siAllowance in employeeSIReport.PayrunSIAllowancesSummaries)
                    {
                        DynamicHelper.AddProperty(siDSRow, $"{siAllowance.AllowanceType.Value}_Value", "" + siAllowance.Value.ToString("N2"));
                    }

                    double totalSISalary = employeeSIReport.TotalSISalary;
                    siDSRow.getEmpTotalSalaryForSI = "" + totalSISalary.ToString("N2");

                    List <(string title, double value)> Contributions = new List <(string title, double value)>();
                    foreach (SIContributionCategory_Dto SIC in SIContributionCategories)
                    {
                        foreach (SIContribution_Dto SICC in SIC.SIContributions)
                        {
                            double SICCCV       = SICC.IsPercentage ? totalSISalary * (SICC.Value / 100) : SICC.Value;
                            int    contribIndex = Contributions.FindIndex(x => x.title == SICC.Title);
                            if (contribIndex != -1)
                            {
                                Contributions[contribIndex] = (SICC.Title, Contributions[contribIndex].value + SICCCV);
                            }
                            else
                            {
                                Contributions.Add((SICC.Title, SICCCV));
                            }
                            DynamicHelper.AddProperty(siDSRow, $"{SIC.Title}_{SICC.Title}_Value", $"{SICCCV.ToString("N2")}");
                        }
                    }

                    foreach ((string title, double value)SICC in Contributions)
                    {
                        List <SIContribution_Dto> sIContributions = SIContributionCategories.SelectMany(x => x.SIContributions).ToList();
                        DynamicHelper.AddProperty(siDSRow, $"Overall_{SICC.title}_Value", $"{SICC.value.ToString("N2")}");
                    }

                    siDSRow.month = curDetail.Month;
                    siDSRow.year  = curDetail.Year;

                    dynamicDS.Add(siDSRow);
                }

                //JsonResult eosbDSJson = new JsonResult(dynamicDS);

                dynamic Model = new ExpandoObject();
                Model.SIDS     = dynamicDS;
                Model.month    = payrun.Month;
                Model.year     = payrun.Year;
                Model.isPosted = payrun.IsSIPosted;
                return(new JsonResult(Model));
            }
            return(StatusCode(500));
        }
Ejemplo n.º 24
0
 public void RemoveContributions()
 {
     Contributions.Clear();
 }
Ejemplo n.º 25
0
        private static async Task TestContributionAsync()
        {
            IEnumerable <AwardContribution> contributionAreas = null;

            try
            {
                contributionAreas = await App.API.GetContributionAreasAsync();
            }
            catch (Exception ex)
            {
                await MessageDialogManager.Current.ShowAsync(
                    "Error",
                    $"Error in GetContributionAreasAsync method. Error: {ex}");
            }

            Contributions contributions = null;

            try
            {
                contributions = await App.API.GetContributionsAsync(0, 25);
            }
            catch (Exception ex)
            {
                await MessageDialogManager.Current.ShowAsync(
                    "Error",
                    $"Error in GetContributionsAsync method. Error: {ex}");
            }

            if (contributions != null)
            {
                try
                {
                    Contribution ctb = contributions.Items.FirstOrDefault();

                    Contribution contribution = await App.API.GetContributionByIdAsync(ctb.Id.Value);
                }
                catch (Exception ex)
                {
                    await MessageDialogManager.Current.ShowAsync(
                        "Error",
                        $"Error in GetContributionByIdAsync method. Error: {ex}");
                }
            }

            IEnumerable <ContributionType> contributionTypes = null;

            try
            {
                contributionTypes = await App.API.GetContributionTypesAsync();
            }
            catch (Exception ex)
            {
                await MessageDialogManager.Current.ShowAsync(
                    "Error",
                    $"Error in GetContributionTypesAsync method. Error: {ex}");
            }

            if (contributionTypes != null && contributionAreas != null)
            {
                ContributionType  contributionType  = contributionTypes.FirstOrDefault();
                AwardContribution awardContribution = contributionAreas.FirstOrDefault();
                ContributionArea  area = awardContribution.Areas.FirstOrDefault();

                ContributionTechnology technology = new ContributionTechnology
                {
                    AwardCategory = awardContribution.AwardCategory,
                    AwardName     = area.AwardName,
                    Id            = area.Items.FirstOrDefault().Id,
                    Name          = area.Items.FirstOrDefault().Name
                };

                Contribution newContribution = new Contribution
                {
                    Id           = 0,
                    Type         = contributionType,
                    TypeName     = contributionType.Name,
                    Technology   = technology,
                    StartDate    = DateTime.Now,
                    Title        = "MVP API Test",
                    ReferenceUrl =
                        "https://github.com/jamesmcroft/mvp-api-portable",
                    Visibility =
                        new ItemVisibility
                    {
                        Id          = 299600000,
                        Description = "Everyone",
                        LocalizeKey =
                            "PublicVisibilityText"
                    },
                    AnnualQuantity       = 0,
                    SecondAnnualQuantity = 0,
                    AnnualReach          = 0,
                    Description          = "Hello, World!"
                };

                Contribution submittedContribution = null;

                try
                {
                    submittedContribution = await App.API.AddContributionAsync(newContribution);
                }
                catch (Exception ex)
                {
                    await MessageDialogManager.Current.ShowAsync(
                        "Error",
                        $"Error in AddContributionAsync method. Error: {ex}");
                }

                if (submittedContribution != null)
                {
                    submittedContribution.Description = "This is a new description";

                    try
                    {
                        bool updated = await App.API.UpdateContributionAsync(submittedContribution);
                    }
                    catch (Exception ex)
                    {
                        await MessageDialogManager.Current.ShowAsync(
                            "Error",
                            $"Error in UpdateContributionAsync method. Error: {ex}");
                    }

                    try
                    {
                        bool deleted = await App.API.DeleteContributionAsync(submittedContribution.Id.Value);
                    }
                    catch (Exception ex)
                    {
                        await MessageDialogManager.Current.ShowAsync(
                            "Error",
                            $"Error in DeleteContributionAsync method. Error: {ex}");
                    }
                }
            }
        }
Ejemplo n.º 26
0
 /// <summary>
 /// Handles refreshing after adding.
 /// </summary>
 void HandleContributionDeleteMessage(MessagingService obj, Contribution contribution)
 {
     State = LayoutState.Loading;
     Contributions.Remove(contribution);
     State = LayoutState.None;
 }
Ejemplo n.º 27
0
 public static Contributions CreateTestContributions()
 {
     Contributions contributions = new Contributions()
     {
         SiteType = SiteType.Undefined,
         InstanceCreatedDateTime = DateTime.Now,
         ItemsPerPage = 20,
         SortDirection = SortDirection.Ascending,
         StartIndex = 0,
         IdentityUserID = "77",
         ContributionItems = new List<Contribution>() 
         { 
             new Contribution()
             {
                  Body = "First Item Body",                         
                  ModerationStatus = CommentStatus.Hidden.NotHidden,
                  PostIndex = 0,
                  SiteName = "h2g2",
                  SiteType = BBC.Dna.Sites.SiteType.Blog,
                  FirstSubject = "Test Instance Source Title",
                  Subject = "Test Instance Sub Title",
                  Timestamp = new DateTimeHelper(DateTime.Now),
                  Title = "Test Instance Title"
             },
             new Contribution()
             {
                  Body = "Second Item Body",                         
                  ModerationStatus = CommentStatus.Hidden.NotHidden,
                  PostIndex = 1,
                  SiteName = "h2g2",
                  SiteType = BBC.Dna.Sites.SiteType.Messageboard,
                  FirstSubject = "Test Instance Source Title 2",
                  Subject = "Test Instance Sub Title 2",
                  Timestamp = new DateTimeHelper(DateTime.Now),
                  Title = "Test Instance Title 2"
             }
         }
     };
     return contributions;
 }
Ejemplo n.º 28
0
        public ActionResult GetContributionSummary()
        {
            var    user       = UserManager.Users.Where(x => x.UserName == User.Identity.Name).First();
            string SchemeName = PensionSetup.GetSchemeNameAsync(user.SponsorNumber);

            ContributionSummary_Service contributionService = new ContributionSummary_Service();

            contributionService.Url = "http://" + PensionSetup.ServerName + ":" + PensionSetup.ServerPort + "/" + PensionSetup.ServerInstance + "/WS/" + SchemeName + "/Page/ContributionSummary";
            contributionService.UseDefaultCredentials = false;
            contributionService.Credentials           = new NetworkCredential(PensionSetup.SoapUsername, PensionSetup.SoapPassword);

            List <ContributionSummary_Filter> filterArray = new List <ContributionSummary_Filter>();
            ContributionSummary_Filter        nameFilter  = new ContributionSummary_Filter();

            string MemberNumber = user.MemberNumber;

            nameFilter.Field    = ContributionSummary_Fields.Vendor_No;
            nameFilter.Criteria = MemberNumber;

            filterArray.Add(nameFilter);


            ContributionSummary[] contribution = contributionService.ReadMultiple(filterArray.ToArray(), null, 0);

            DateTime startDate = contribution.Where(m => m.Vendor_No == MemberNumber).Select(d => d.Min_Cont_Date).First();
            DateTime endDate   = contribution.Where(m => m.Vendor_No == MemberNumber).First().Max_Cont_Date;

            int     startD = startDate.Year;
            int     endD   = endDate.Year;
            decimal result = 0;
            decimal unregEmployeeAmount = 0;
            decimal regEmployeeAmount   = 0;

            decimal unregEmployerAmount = 0;
            decimal regEmployerAmount   = 0;

            decimal regEmployeeAdditionalAmount = 0;
            decimal regEmployerAdditionalAmount = 0;

            decimal unregEmployeeAdditionalAmount = 0;
            decimal unregEmployerAdditionalAmount = 0;

            decimal Pre90EEAmount = 0;
            decimal Pre90ERAmount = 0;

            List <Contributions> contributionArray = new List <Contributions>();

            for (var currentYear = startD; currentYear <= endD; currentYear++)
            {
                result = contribution.Where(r => (int)r.Contribution_Type == 1 &&
                                            (int)r.Exemption_Type == 1 &&
                                            (int)r.Transaction_Type == 1 &&
                                            r.Contribution_Period.Year == currentYear)
                         .Select(r => r.Amount_LCY)
                         .Sum();

                if (result == 0)
                {
                    regEmployeeAmount = 0;
                }
                else
                {
                    regEmployeeAmount = result;
                }

                result = contribution.Where(r => (int)r.Contribution_Type == 5 &&
                                            (int)r.Transaction_Type == 1 &&
                                            (int)r.Exemption_Type == 2 &&
                                            r.Contribution_Period.Year == currentYear)
                         .Select(x => x.Amount_LCY)
                         .Sum();

                if (result == 0)
                {
                    unregEmployeeAmount = 0;
                }
                else
                {
                    unregEmployeeAmount = result;
                }

                var totalEmployeeContribution = regEmployeeAmount + unregEmployeeAmount;

                result = contribution.Where(c => (int)c.Contribution_Type == 2 &&
                                            (int)c.Transaction_Type == 1 &&
                                            (int)c.Exemption_Type == 1 &&
                                            c.Contribution_Period.Year == currentYear).Select(x => x.Amount_LCY).Sum();

                if (result == 0)
                {
                    regEmployerAmount = 0;
                }
                else
                {
                    regEmployerAmount = result;
                }

                result = contribution.Where(c => (int)c.Contribution_Type == 6 &&
                                            (int)c.Transaction_Type == 1 &&
                                            (int)c.Exemption_Type == 2 &&
                                            c.Contribution_Period.Year == currentYear)
                         .Select(x => x.Amount_LCY)
                         .Sum();

                if (result == 0)
                {
                    unregEmployerAmount = 0;
                }
                else
                {
                    unregEmployerAmount = result;
                }

                var totalEmployerContribution = regEmployerAmount + unregEmployerAmount;

                result = contribution.Where(c => (int)c.Contribution_Type == 4 &&
                                            (int)c.Transaction_Type == 1 &&
                                            (int)c.Exemption_Type == 1 &&
                                            c.Contribution_Period.Year == currentYear)
                         .Select(x => x.Amount_LCY)
                         .Sum();

                if (result == 0)
                {
                    regEmployeeAdditionalAmount = 0;
                }
                else
                {
                    regEmployeeAdditionalAmount = result;
                }

                result = contribution.Where(c => (int)c.Contribution_Type == 10 &&
                                            (int)c.Transaction_Type == 1 &&
                                            (int)c.Exemption_Type == 2 &&
                                            c.Contribution_Period.Year == currentYear)
                         .Select(x => x.Amount_LCY)
                         .Sum();

                if (result == 0)
                {
                    unregEmployeeAdditionalAmount = 0;
                }
                else
                {
                    unregEmployeeAdditionalAmount = result;
                }

                var totalAdditionalEmployeeContribution = regEmployeeAdditionalAmount + unregEmployeeAdditionalAmount;

                result = contribution.Where(c => (int)c.Contribution_Type == 3 &&
                                            (int)c.Transaction_Type == 1 &&
                                            (int)c.Exemption_Type == 1 &&
                                            c.Contribution_Period.Year == currentYear)
                         .Select(x => x.Amount_LCY)
                         .Sum();

                if (result == 0)
                {
                    regEmployerAdditionalAmount = 0;
                }
                else
                {
                    regEmployerAdditionalAmount = result;
                }

                result = contribution.Where(c => (int)c.Contribution_Type == 11 &&
                                            (int)c.Transaction_Type == 1 &&
                                            (int)c.Exemption_Type == 2 &&
                                            c.Contribution_Period.Year == currentYear)
                         .Select(x => x.Amount_LCY)
                         .Sum();

                if (result == 0)
                {
                    unregEmployerAdditionalAmount = 0;
                }
                else
                {
                    unregEmployerAdditionalAmount = result;
                }

                result = contribution.Where(c => (int)c.Contribution_Type == 12 &&
                                            (int)c.Transaction_Type == 1 &&
                                            (int)c.Exemption_Type == 2 &&
                                            c.Contribution_Period.Year == currentYear)
                         .Select(x => x.Amount_LCY)
                         .Sum();

                if (result == 0)
                {
                    Pre90EEAmount = 0;
                }
                else
                {
                    Pre90EEAmount = result;
                }

                result = contribution.Where(c => (int)c.Contribution_Type == 13 &&
                                            (int)c.Transaction_Type == 1 &&
                                            (int)c.Exemption_Type == 2 &&
                                            c.Contribution_Period.Year == currentYear)
                         .Select(x => x.Amount_LCY)
                         .Sum();

                if (result == 0)
                {
                    Pre90ERAmount = 0;
                }
                else
                {
                    Pre90ERAmount = result;
                }


                var totalAdditionalEmployerContribution = regEmployerAdditionalAmount + unregEmployerAdditionalAmount;
                var avc        = totalAdditionalEmployeeContribution + totalAdditionalEmployerContribution;
                var totalPRE90 = Pre90EEAmount + Pre90ERAmount;

                var totalContribution = totalEmployeeContribution + totalEmployerContribution + totalAdditionalEmployeeContribution + totalAdditionalEmployerContribution + totalPRE90;

                if (totalContribution == 0)
                {
                    continue;
                }

                var arr = new Contributions
                {
                    TOTAL_EMPLOYEE_CONTRIBUTION = System.Math.Abs(totalEmployeeContribution),
                    REG_EMPLOYER_CONTRIBUTION   = System.Math.Abs(regEmployerAmount),
                    UNREG_EMPLOYER_CONTRIBUTION = System.Math.Abs(unregEmployerAmount),

                    TOTAL_EMPLOYER_CONTRIBUTION = System.Math.Abs(totalEmployerContribution),
                    REG_EMPLOYEE_CONTRIBUTION   = System.Math.Abs(regEmployeeAmount),
                    UNREG_EMPLOYEE_CONTRIBUTION = System.Math.Abs(unregEmployeeAmount),

                    TOTAL_ADDITIONAL_EMPLOYER_CONTRIBUTION = System.Math.Abs(totalAdditionalEmployerContribution),
                    TOTAL_ADDITIONAL_EMPLOYEE_CONTRIBUTION = System.Math.Abs(totalAdditionalEmployeeContribution),
                    AVC       = avc,
                    REG_AVC   = System.Math.Abs(regEmployerAdditionalAmount + regEmployeeAdditionalAmount),
                    UNREG_AVC = System.Math.Abs(unregEmployerAdditionalAmount + unregEmployeeAdditionalAmount),

                    TOTAL_PRE_90    = System.Math.Abs(totalPRE90),
                    PRE_90_EE       = System.Math.Abs(Pre90EEAmount),
                    PRE_90_ER       = System.Math.Abs(Pre90ERAmount),
                    TOTAL_PRE_90_EE = System.Math.Abs(Pre90EEAmount),
                    TOTAL_PRE_90_ER = System.Math.Abs(Pre90ERAmount),

                    TOTAL_CONTRIBUTION = System.Math.Abs(totalContribution),
                    FMT_TOTAL_EMPLOYEE_CONTRIBUTION = System.Math.Abs(totalEmployeeContribution),
                    FMT_TOTAL_EMPLOYER_CONTRIBUTION = System.Math.Abs(totalEmployerContribution),
                    FMT_AVC = System.Math.Abs(avc),

                    FMT_TOTAL_CONTRIBUTION = System.Math.Abs(totalContribution),
                    YEAR = currentYear
                };

                contributionArray.Add(arr);
            }


            return(Json(contributionArray, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 29
0
 public void AssignContribution(Contribution contribution)
 {
     Contributions.Add(contribution);
     contribution.Contributor = this;
 }
Ejemplo n.º 30
0
 public void AddContribution(Contributions contribution)
 {
     lock (contributions)
     {
         if (!IsContributingAs(contribution))
         {
             contributions.Add(contribution);
         }
     }
 }
Ejemplo n.º 31
0
 public void AddContribution(Contribution contribution)
 {
     Contributions.Add(contribution);
 }
Ejemplo n.º 32
0
 public void RemoveContribution(Contributions contribution)
 {
     lock (contributions)
     {
         contributions = contributions.Where(r => !r.Equals(contribution)).ToList();
     }
 }