public static IEnumerable <ResultPack> EvaluateConcept(ConfigBase evalConfig, Period evalPeriod, IPeriodProfile evalProfile, Result <MasterItem.EvaluateSource, string> prepValues) { IEmployProfile conceptProfile = evalProfile.Employ(); if (conceptProfile == null) { return(EvaluateUtils.DecoratedError(CONCEPT_DESCRIPTION_ERROR_FORMAT, CONCEPT_PROFILE_NULL_TEXT)); } MasterItem.EvaluateSource conceptValues = prepValues.Value; // EVALUATION TSeconds[] positionMonth = PeriodUtils.EmptyMonthSchedule(); foreach (var absence in conceptValues.AbsenceList) { positionMonth = PeriodUtils.ScheduleFromTemplateStopInc(positionMonth, absence.ScheduleMonth, conceptValues.DayPositionFrom, conceptValues.DayPositionStop); } // EVALUATION IArticleResult conceptResult = new ArticleGeneralResult(evalConfig); // SET RESULT VALUES conceptResult.AddWorkMonthTermScheduleValue(positionMonth); // SET RESULT VALUES return(EvaluateUtils.Results(conceptResult)); }
private void LoadYearCombo() { //Set the combo data source cmbYear.DataSource = PeriodUtils.GetYears(); cmbYear.DataBind(); cmbYear.SelectedIndex = cmbYear.Items.Count - 1 - ApplicationConstants.YEAR_AHEAD_TO_INCLUDE; /*select curent year*/ }
public static IEnumerable <ResultPack> EvaluateConcept(ConfigBase evalConfig, Period evalPeriod, IPeriodProfile evalProfile, Result <MasterItem.EvaluateSource, string> prepValues) { IEmployProfile conceptProfile = evalProfile.Employ(); if (conceptProfile == null) { return(EvaluateUtils.DecoratedError(CONCEPT_DESCRIPTION_ERROR_FORMAT, CONCEPT_PROFILE_NULL_TEXT)); } MasterItem.EvaluateSource conceptValues = prepValues.Value; // EVALUATION TSeconds[] absencseMonth = PeriodUtils.ScheduleFromTimesheet( conceptValues.ScheduleMonth, conceptValues.SchedulePiece, conceptValues.ScheduleHours, conceptValues.DayFrom, conceptValues.DayStop); // EVALUATION IArticleResult conceptResult = new ArticleGeneralResult(evalConfig); // SET RESULT VALUES conceptResult.AddMonthAttendanceScheduleValue(conceptValues.DayFrom, conceptValues.DayStop, absencseMonth); // SET RESULT VALUES return(EvaluateUtils.Results(conceptResult)); }
public static IEnumerable <ResultPack> EvaluateConcept(ConfigBase evalConfig, Period evalPeriod, IPeriodProfile evalProfile, Result <MasterItem.EvaluateSource, string> prepValues) { IEmployProfile conceptProfile = evalProfile.Employ(); if (conceptProfile == null) { return(EvaluateUtils.DecoratedError(CONCEPT_DESCRIPTION_ERROR_FORMAT, CONCEPT_PROFILE_NULL_TEXT)); } MasterItem.EvaluateSource conceptValues = prepValues.Value; // EVALUATION TSeconds[] contractMonth = PeriodUtils.EmptyMonthSchedule(); TDay periodDay = 1; foreach (var position in conceptValues.PositionList) { contractMonth = PeriodUtils.ScheduleFromTemplateStopInc(contractMonth, position.ScheduleWorks, position.DayPeriodFrom, position.DayPeriodStop); periodDay = (TDay)(position.DayPeriodStop + 1); } // EVALUATION IArticleResult conceptResult = new ArticleGeneralResult(evalConfig); // SET RESULT VALUES conceptResult.AddWorkMonthRealScheduleValue(contractMonth); // SET RESULT VALUES return(EvaluateUtils.Results(conceptResult)); }
public int WeekDayOfMonth(int dayOrdinal) { DateTime periodDate = DateOfMonth(dayOrdinal); int periodDateCwd = (int)periodDate.DayOfWeek; return(PeriodUtils.DayOfWeekMonToSun(periodDateCwd)); }
private void LoadYearCombo() { cmbYear.Items.Add(new Telerik.Web.UI.RadComboBoxItem(String.Empty, ApplicationConstants.INT_NULL_VALUE.ToString())); cmbYear.DataSource = PeriodUtils.GetYears(); cmbYear.DataBind(); cmbYear.Text = DateTime.Now.Year.ToString(); }
public static void PrevDateRange(this PeriodFilterModel periodFilter) { periodFilter.IsDateRangeFilling = true; var dateRange = PeriodUtils.GetPrevDateRange(periodFilter.PeriodType, periodFilter.DateFrom, periodFilter.DateUntil); periodFilter.DateFrom = dateRange.DateFrom; periodFilter.DateUntil = dateRange.DateUntil; periodFilter.IsDateRangeFilling = false; }
public override EvaluateSource GetNewValues(EvaluateSource initValues) { ConfigCode scheduledCode = (ConfigCode)ArticleCodeCz.FACT_POSITION_SCHEDULE; ConfigCode timesheetCode = (ConfigCode)ArticleCodeCz.FACT_POSITION_TIMESHEET; ConfigCode worksheetCode = (ConfigCode)ArticleCodeCz.FACT_POSITION_WORKING; Result <WeekScheduleValue, string> fullWeekResult = InternalValues .FindResultValue <ArticleGeneralResult, WeekScheduleValue>( TargetFilters.TargetCodePlusPartFunc(scheduledCode, InternalTarget.Head(), InternalTarget.Part()), (x) => (x.IsFullWeeksValue())); Result <WeekScheduleValue, string> realWeekResult = InternalValues .FindResultValue <ArticleGeneralResult, WeekScheduleValue>( TargetFilters.TargetCodePlusPartFunc(scheduledCode, InternalTarget.Head(), InternalTarget.Part()), (x) => (x.IsRealWeeksValue())); Result <MonthScheduleValue, string> timesheetResult = InternalValues .FindResultValue <ArticleGeneralResult, MonthScheduleValue>( TargetFilters.TargetCodePlusPartFunc(timesheetCode, InternalTarget.Head(), InternalTarget.Part()), (x) => (x.IsRealMonthValue())); Result <MonthScheduleValue, string> worksheetResult = InternalValues .FindResultValue <ArticleGeneralResult, MonthScheduleValue>( TargetFilters.TargetCodePlusPartFunc(worksheetCode, InternalTarget.Head(), InternalTarget.Part()), (x) => (x.IsTermMonthValue())); if (ResultMonadUtils.HaveAnyResultFailed( fullWeekResult, realWeekResult, timesheetResult, worksheetResult)) { return(ReturnFailureAndError(initValues, ResultMonadUtils.FirstFailedResultError( fullWeekResult, realWeekResult, timesheetResult, worksheetResult))); } WeekScheduleValue fullWeekValues = fullWeekResult.Value; WeekScheduleValue realWeekValues = realWeekResult.Value; MonthScheduleValue timesheetValues = timesheetResult.Value; MonthScheduleValue worksheetValues = worksheetResult.Value; return(new EvaluateSource { // PROPERTIES SET MonthlyAmount = initValues.MonthlyAmount, ShiftLiable = PeriodUtils.TotalWeekHours(fullWeekValues.HoursWeek), ShiftWorked = PeriodUtils.TotalWeekHours(realWeekValues.HoursWeek), HoursLiable = PeriodUtils.TotalMonthHours(timesheetValues.HoursMonth), HoursWorked = PeriodUtils.TotalMonthHours(worksheetValues.HoursMonth), // PROPERTIES SET }); }
protected override bool ValidatePost(System.Web.Http.ModelBinding.ModelStateDictionary validationDictionary, Client currentClient, Period entity, object param, params object[] additionalObjects) { if (param != null && entity != null && entity.End != null && entity.Begin != null && entity.Days > 0) { List <Period> periodList = PeriodRepository.GetPeriodByDates(entity.Begin, entity.End, currentClient.Id).ToList(); if (PeriodUtils.IsDaysCross(periodList, entity)) { validationDictionary.AddModelError(TypeOfName.GetNameFromType <Period>(), GenericError.ALREADY_EXISTS); } } return(CommonValidation(validationDictionary, currentClient, entity, param, additionalObjects)); }
protected override bool CommonValidation(System.Web.Http.ModelBinding.ModelStateDictionary validationDictionary, Client currentClient, Booking entity, object param, params object[] additionalObjects) { double elapsed; // If DateDeparture - DateArrive < 1 or if the booking time is more than 365 days if (entity.DateArrival != null && entity.DateDeparture != null && ((elapsed = DateUtils.GetElapsedDaysFromDateTimes(entity.DateArrival, entity.DateDeparture)) < 1 || elapsed > MAX_NIGHTS)) { validationDictionary.AddModelError("Dates", GenericError.WRONG_DATA); } if (entity.DateArrival != null && entity.DateDeparture != null && !PeriodUtils.AllCovered(PeriodRepository.GetPeriodByDates((DateTime)entity.DateArrival, (DateTime)entity.DateDeparture, currentClient.Id).ToList(), (DateTime)entity.DateArrival, (DateTime)entity.DateDeparture)) { validationDictionary.AddModelError("Period", GenericError.DOES_NOT_MEET_REQUIREMENTS); } return(validationDictionary.IsValid); }
public void AllCoveredShouldReturnTrue() { List <Period> periods = new List <Period>() { new Period() { Begin = new DateTime(2015, 3, 5, 0, 0, 0), End = new DateTime(2015, 3, 9, 23, 59, 59), Days = 1 | 8 | 16 | 32 | 64, IsClosed = false }, new Period() { Begin = new DateTime(2015, 3, 10, 0, 0, 0), End = new DateTime(2015, 3, 13, 23, 59, 59), Days = 2 | 8 | 16, IsClosed = false }, new Period() { Begin = new DateTime(2015, 3, 10, 0, 0, 0), End = new DateTime(2015, 3, 13, 23, 59, 59), Days = 4, IsClosed = false }, new Period() { Begin = new DateTime(2015, 3, 14, 0, 0, 0), End = new DateTime(2015, 3, 15, 23, 59, 59), Days = 32 | 64, IsClosed = false }, new Period() { Begin = new DateTime(2015, 3, 16, 0, 0, 0), End = new DateTime(2015, 3, 29, 23, 59, 59), Days = 1 | 2 | 4 | 8 | 16 | 32 | 64, IsClosed = false }, }; Assert.IsTrue(PeriodUtils.AllCovered(periods, new DateTime(2015, 3, 9, 14, 0, 0), new DateTime(2015, 3, 29, 10, 0, 0))); }
public void IsDayCrossTestReturnTrue() { List <Period> periods = new List <Period>() { new Period() { Begin = new DateTime(2015, 3, 5, 0, 0, 0), End = new DateTime(2015, 3, 9, 23, 59, 59), Days = 1, IsClosed = false }, new Period() { Begin = new DateTime(2015, 3, 10, 0, 0, 0), End = new DateTime(2015, 3, 13, 23, 59, 59), Days = 2 | 64 | 16, IsClosed = false }, new Period() { Begin = new DateTime(2015, 3, 10, 0, 0, 0), End = new DateTime(2015, 3, 13, 23, 59, 59), Days = 4 | 32, IsClosed = false }, new Period() { Begin = new DateTime(2015, 3, 16, 0, 0, 0), End = new DateTime(2015, 3, 29, 23, 59, 59), Days = 8, IsClosed = false }, }; Assert.IsTrue(PeriodUtils.IsDaysCross(periods, new Period() { Begin = new DateTime(2015, 3, 5, 0, 0, 0), End = new DateTime(2015, 3, 29, 23, 59, 59), Days = 16, IsClosed = false })); }
private List <ReportUnit> BuildReportUnits(IEnumerable <ITransaction> transactions, PeriodType periodType, DateTime dateFrom, DateTime dateUntil) { var result = new List <ReportUnit>(); var periods = PeriodUtils.SplitDateRange(periodType, dateFrom, dateUntil); foreach (var period in periods) { // get transactions for the correspond date range var periodTransactions = transactions .Where(x => x.TransactionDate >= period.DateFrom && x.TransactionDate <= period.DateUntil); // create report unit var reportUnit = new ReportUnit { Caption = PeriodUtils.GetPeriodRangeDetails(periodType, period.DateFrom, period.DateUntil), Amount = Math.Abs(periodTransactions.Sum(_ => ToMainCurrency(_.TransactionAmount, _.TransactionCurrencyId))) }; // add report unit to result list result.Add(reportUnit); } return(result); }
private void UpdatePrices(List <Period> listPeriod, DateTime begin, DateTime end, Client currentClient, int coeff, int?peopleCategoryId = null) { DateTime dateNights = begin; PricePerPerson ppp = null; for (; dateNights.Date < end.Date; dateNights = dateNights.AddDays(1)) { Period currentPeriod = PeriodUtils.GetCorrecPeriod(listPeriod.Where(p => dateNights >= p.Begin && dateNights <= p.End).ToList(), dateNights); if (currentPeriod == null) { validationDictionnary.AddModelError(String.Format(GenericNames.MODEL_STATE_FORMAT, TypeOfName.GetNameFromType <RoomBooking>(), "Period"), GenericError.CANNOT_BE_NULL_OR_EMPTY); return; } repo.includes.Add("Tax"); if (peopleCategoryId == null) { ppp = repo.GetPricePerPersonForGivenPeriodAndRoom(currentPeriod.Id, orig.Room.Id, currentClient.Id); } else { ppp = repo.GetPricePerPersonForGivenPeriodPeopleCategoryAndRoom(currentPeriod.Id, (int)peopleCategoryId, orig.Room.Id, currentClient.Id); } if (ppp == null) { validationDictionnary.AddModelError(String.Format(GenericNames.MODEL_STATE_FORMAT, TypeOfName.GetNameFromType <RoomBooking>(), "PricePerPerson"), GenericError.CANNOT_BE_NULL_OR_EMPTY); return; } Decimal tmpTTC = (Decimal)(ppp.PriceHT) * coeff; if (ppp.Tax != null) { tmpTTC = ComputePrice.ComputePriceFromPercentOrAmount(tmpTTC, (EValueType)ppp.Tax.ValueType, (EValueType)ppp.Tax.ValueType == EValueType.AMOUNT ? (Decimal)ppp.Tax.Price * coeff : (Decimal)ppp.Tax.Price); } finalPriceHT += (Decimal)(ppp.PriceHT) * coeff; finalPriceTTC += tmpTTC; } }
public static IEnumerable <ResultPack> EvaluateConcept(ConfigBase evalConfig, Period evalPeriod, IPeriodProfile evalProfile, Result <MasterItem.EvaluateSource, string> prepValues) { IEmployProfile conceptProfile = evalProfile.Employ(); if (conceptProfile == null) { return(EvaluateUtils.DecoratedError(CONCEPT_DESCRIPTION_ERROR_FORMAT, CONCEPT_PROFILE_NULL_TEXT)); } MasterItem.EvaluateSource conceptValues = prepValues.Value; // EVALUATION TSeconds[] scheduleWorked = PeriodUtils.ScheduleBaseSubtract( conceptValues.ScheduleMonth, conceptValues.AbsencesMonth, 1, 31); // EVALUATION IArticleResult conceptResult = new ArticleGeneralResult(evalConfig); // SET RESULT VALUES conceptResult.AddWorkMonthTermScheduleValue(scheduleWorked); // SET RESULT VALUES return(EvaluateUtils.Results(conceptResult)); }