Exemple #1
0
        private List <AbsencePolicyEntitlement> GenerateAbsencePolicyAbsenceTypeEntitlements(IEnumerable <AbsencePolicyEntitlement> absencePolicyEntitlements, AbsencePolicyPeriod absencePolicyPeriod)
        {
            var absencePeriodAbsencePolicyAbsenceTypeEntitlements = new List <AbsencePolicyEntitlement>();

            if (absencePolicyPeriod == null)
            {
                return(null);
            }

            if (absencePolicyEntitlements != null)
            {
                foreach (var dcEntitlement in absencePolicyEntitlements)
                {
                    dcEntitlement.StartDate = absencePolicyPeriod.AbsencePeriod.StartDate;
                    if (dcEntitlement.Frequency.Name.Trim().ToLower() == "yearly")
                    {
                        dcEntitlement.EndDate = absencePolicyPeriod.AbsencePeriod.EndDate;
                        absencePeriodAbsencePolicyAbsenceTypeEntitlements.Add(dcEntitlement);
                    }
                    else
                    {
                        dcEntitlement.EndDate = absencePolicyPeriod.AbsencePeriod.StartDate.AddMonths(3).AddDays(-1);
                        absencePeriodAbsencePolicyAbsenceTypeEntitlements.Add(dcEntitlement);
                        for (int i = 1; i < 4; i++)
                        {
                            var extraEntitlement = dcEntitlement.Copy();
                            extraEntitlement.StartDate = absencePolicyPeriod.AbsencePeriod.StartDate.AddMonths(i * 3);
                            extraEntitlement.EndDate   = extraEntitlement.StartDate.Value.AddMonths(3).AddDays(-1);
                            absencePeriodAbsencePolicyAbsenceTypeEntitlements.Add(extraEntitlement);
                        }
                    }
                }
            }

            // Set to -1 so we can set to null later

            var nullOthersEntitlement = new AbsencePolicyEntitlement
            {
                OrganisationId      = absencePolicyPeriod.OrganisationId,
                AbsenceTypeId       = 0,
                FrequencyId         = 1,
                Entitlement         = 0,
                MaximumCarryForward = 0,
                AbsencePolicyId     = absencePolicyPeriod.AbsencePolicyId,
                Frequency           = new Frequency {
                    FrequencyId = 1, Name = "yearly"
                },
                StartDate = absencePolicyPeriod.AbsencePeriod.StartDate,
                EndDate   = absencePolicyPeriod.AbsencePeriod.EndDate,
                //HasEntitlement = false
            };

            absencePeriodAbsencePolicyAbsenceTypeEntitlements.Add(nullOthersEntitlement);
            return(absencePeriodAbsencePolicyAbsenceTypeEntitlements);
        }
Exemple #2
0
 public AbsencePolicyPeriod CreateAbsencePolicyAbsencePeriod(int organisationId, AbsencePolicyPeriod absencePolicyPeriod)
 {
     using (var context = _databaseFactory.Create(organisationId))
     {
         var result = context.AbsencePolicyPeriods.Add(absencePolicyPeriod);
         context.SaveChanges();
         return(result);
     }
 }
Exemple #3
0
        public AbsencePolicyPeriod CreateAbsencePolicyAbsencePeriod(int organisationId, AbsencePolicyPeriod absencePolicyPeriod)
        {
            absencePolicyPeriod = _hrDataService.CreateAbsencePolicyAbsencePeriod(organisationId, absencePolicyPeriod);
            var employments = _hrDataService.RetrieveActiveEmploymentsByAbsencePolicy(organisationId, absencePolicyPeriod.AbsencePolicyId);

            CreatePersonnelAbsenceEntitlements(organisationId, employments, absencePolicyPeriod.AbsencePolicyId);
            return(absencePolicyPeriod);
        }
Exemple #4
0
 public ActionResult CreateAbsencePolicyPeriod(AbsencePolicyPeriod absencePolicyPeriod)
 {
     return(this.JsonNet(HRBusinessService.CreateAbsencePolicyAbsencePeriod(UserOrganisationId, absencePolicyPeriod)));
 }