Example #1
0
        public virtual SalaryScale InitializedCopy()
        {
            SalaryScale retval = new SalaryScale()
            {
                _BargainingCode = this._BargainingCode,
                _EffectiveDate  = DateTime.Today,
                _NumSalarySteps = this._NumSalarySteps,
                _Title          = this._Title,
                _TitleCode      = this._TitleCode,
                SalaryGrade     = this.SalaryGrade
            };

            // Create a new SalaryGradeQuartiles and add it to the SalaryScale:

            /*
             * retval.SalaryGradeQuartiles = new SalaryGradeQuartiles()
             * {
             *  EffectiveDate = DateTime.Today,
             *  SalaryGrade = this.SalaryGrade
             * };
             * */
            // Not sure if I need this or NHibernate will take care of this for me.
            //retval.SalaryGradeQuartiles.SalaryScales.Add(retval);

            // Take care of creating initialized copies of the salary steps:
            List <SalaryStep> ss = new List <SalaryStep>();

            foreach (SalaryStep step in this.SalarySteps)
            {
                ss.Add(step.InitializedCopy(retval));
            }
            retval.SalarySteps = ss; // Assign the newly copied salary steps.

            return(retval);
        }
Example #2
0
 public SalaryStep(SalaryScale salaryScale)
 {
     _EffectiveDate = salaryScale.EffectiveDate;
     _Title         = salaryScale.Title;
     _TitleCode     = salaryScale.TitleCode;
     _SalaryScale   = salaryScale;
 }
Example #3
0
        /// <summary>
        /// Given a title code and date,
        /// return the salary scale that would have been in effect for the date provided.
        /// This is necessary when there are several salary scales for a given title code,
        /// and you do not know the salary scale's actual effective date.
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="titleCode"></param>
        /// <param name="effectiveDate"></param>
        /// <returns>SalaryScale in effect for title code and date provided</returns>
        public static SalaryScale GetEffectiveSalaryScale(IRepository repository, string titleCode, DateTime effectiveDate)
        {
            SalaryScale salaryScale = null;

            var queryable = repository.OfType <SalaryScale>().Queryable;

            var count = queryable.Where(x => x.TitleCode.Equals(titleCode)).Count();

            // Get the corresponding salary scale only if there's salary data available; otherwise, return null
            // and let the view handle displaying the "No Data Found" message.
            if (count > 0)
            {
                if (count == 1)
                {
                    // If there's only 1 salary scale set the return value to it:
                    salaryScale = queryable.Where(x => x.TitleCode.Equals(titleCode)).SingleOrDefault();
                }
                else
                {
                    if (effectiveDate.Equals(new DateTime()))
                    {
                        effectiveDate = DateTime.Now;
                    }
                    // If there's multiple salary scales for the same title code, get the one
                    // whose effective date is equal to or less than the effectiveDate provided:

                    // First find the max effective date for the given title code that is equal to or less than the effectiveDate, i.e. date provided:
                    var maxEffectiveDateForDate =
                        queryable.Where(x => x.TitleCode.Equals(titleCode) && x.EffectiveDate <= effectiveDate).Max(x => x.EffectiveDate);

                    // Set the return value to the one whose effectiveDate matches the maximum effective date determined
                    // in the previous statement:
                    salaryScale = queryable
                                  .Where(x => x.TitleCode.Equals(titleCode) && x.EffectiveDate == maxEffectiveDateForDate)
                                  .FirstOrDefault();

                    //   var conjunction = Restrictions.Conjunction();
                    //   var criteria = NHibernateSessionManager.Instance.GetSession().CreateCriteria(typeof(SalaryScale));
                    //   criteria.CreateAlias("SalarySteps", "SalarySteps")
                    //.AddOrder(Order.Asc("SalarySteps.Annual"))
                    //.SetFetchMode("SalarySteps", FetchMode.Eager);
                    //   conjunction.Add(Restrictions.Eq("TitleCode", titleCode));
                    //   conjunction.Add(Restrictions.Eq("EffectiveDate", maxEffectiveDateForDate));
                    //   criteria.Add(conjunction);
                    //   var ss = criteria.List<SalaryScale>().FirstOrDefault();
                }

                if (salaryScale != null)
                {
                    salaryScale.SalarySteps = repository.OfType <SalaryStep>()
                                              .Queryable
                                              .Where(s => s.TitleCode == salaryScale.TitleCode && s.EffectiveDate == salaryScale.EffectiveDate)
                                              .OrderBy(x => x.Annual)
                                              .ToList();
                }
            }
            // Return the corresponding salary scale (or null if none were available for that title code).
            return(salaryScale);
        }
Example #4
0
        public virtual SalaryStep InitializedCopy(SalaryScale salaryScale)
        {
            SalaryStep ss = new SalaryStep()
            {
                _EffectiveDate = DateTime.Today,
                _StepNumber    = this._StepNumber,
                _Title         = this._Title,
                _TitleCode     = this.TitleCode,
                _SalaryScale   = salaryScale
            };

            return(ss);
        }
Example #5
0
        /// <summary>
        /// Given a SalaryScale, return a Dictionary containing
        /// the corresponding criteria list of selection types, meaning the name and corresponding
        /// salary amount, i.e. "Step 10.0, 65470.00, etc.
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="salaryScale"></param>
        /// <returns>A key/value pair dictionary containing the selection type criteria</returns>
        /// <modifications>2011-12-08 by kjt: Commented out campus average, and Market selections since we either have little or no data; 2011-12-09 by kjt: Added collegeAverage as a param.</modifications>
        public static Dictionary <string, decimal?> GetCriteriaList(IRepository repository, SalaryScale salaryScale, double collegeAverage)
        {
            Check.Require(repository != null, "Repository must be supplied");

            var cl = new Dictionary <string, decimal?>();

            if (salaryScale != null)
            {
                List <SelectionType> selectionTypes = repository.OfType <SelectionType>()
                                                      .Queryable
                                                      //.Where(x => x.ShortType != "Step")
                                                      .OrderBy(s => s.SortOrder)
                                                      .ToList();

                cl.Add(selectionTypes[(int)Domain.SelectionType.Types.NONE].ShortType, null); // "None"

                if (salaryScale.SalarySteps.Count == 0)
                {
                    cl.Add(selectionTypes[(int)Domain.SelectionType.Types.MIN].ShortType,
                           salaryScale.SalaryGradeQuartiles.MinAnnual);        // "Min"
                    cl.Add(selectionTypes[(int)Domain.SelectionType.Types.FIRST].ShortType,
                           salaryScale.SalaryGradeQuartiles.FirstQrtleAnnual); // "1st"
                    cl.Add(selectionTypes[(int)Domain.SelectionType.Types.MID].ShortType,
                           salaryScale.SalaryGradeQuartiles.MidAnnual);        // "Mid"
                    cl.Add(selectionTypes[(int)Domain.SelectionType.Types.THIRD].ShortType,
                           salaryScale.SalaryGradeQuartiles.ThirdQrtleAnnual); // "3rd"
                    cl.Add(selectionTypes[(int)Domain.SelectionType.Types.MAX].ShortType,
                           salaryScale.SalaryGradeQuartiles.MaxAnnual);        // "Max"
                }

                //cl.Add(selectionTypes[(int)Domain.SelectionType.Types.LM_WAS].ShortType, Convert.ToDecimal(salaryScale.LaborMarketWAS)); // "Labor Mkt WAS"
                //cl.Add(selectionTypes[(int)Domain.SelectionType.Types.LM_MID].ShortType, Convert.ToDecimal(salaryScale.LaborMarketMidAnnual)); // "Labor Mkt Mid"
                // This needs to be revised to return the college average for the college average of the employee!!!!
                if (collegeAverage != null && collegeAverage > 0)
                {
                    cl.Add(selectionTypes[(int)Domain.SelectionType.Types.COLLEGE_AVG].ShortType,
                           Convert.ToDecimal(collegeAverage)); // "College AVG"
                }

                //cl.Add(selectionTypes[(int)Domain.SelectionType.Types.COLLEGE_AVG].ShortType, Convert.ToDecimal(salaryScale.CollegeAverageAnnual)); // "College AVG"
                //cl.Add(selectionTypes[(int)Domain.SelectionType.Types.CAMPUS_AVG].ShortType, Convert.ToDecimal(salaryScale.CampusAverageAnnual)); // "Campus AVG"

                // This should never get called unless someone called this method with a SalaryScale that was
                // not fetched using SalaryScale.GetEffectiveSalarryScale(...)
                if (salaryScale.NumSalarySteps > 0 && (salaryScale.SalarySteps.Count != salaryScale.NumSalarySteps))
                {
                    // lazy binding work around to fetch all salary steps:
                    salaryScale.SalarySteps = repository.OfType <SalaryStep>()
                                              .Queryable
                                              .Where(s => s.TitleCode == salaryScale.TitleCode && s.EffectiveDate == salaryScale.EffectiveDate)
                                              .OrderBy(x => x.Annual)
                                              .ToList();
                }

                foreach (var step in salaryScale.SalarySteps)
                {
                    cl.Add(selectionTypes[(int)Domain.SelectionType.Types.STEP].ShortType + " " + step.StepNumber, Convert.ToDecimal(step.Annual)); // "Step"
                }
            }

            return(cl);
        }