public override EvaluateSource GetNewValues(EvaluateSource initValues) { Result <MoneyAmountSum, string> generalBaseResult = GetGeneralBase(InternalValues, InternalTarget); Result <MoneyAmountSum, string> healthsPartResult = GetHealthsPart(InternalValues, InternalTarget); Result <MoneyAmountSum, string> socialsPartResult = GetSocialsPart(InternalValues, InternalTarget); if (ResultMonadUtils.HaveAnyResultFailed(generalBaseResult, healthsPartResult, socialsPartResult)) { return(ReturnFailureAndError(initValues, ResultMonadUtils.FirstFailedResultError(generalBaseResult, healthsPartResult, socialsPartResult))); } MoneyAmountSum generalBaseValues = generalBaseResult.Value; MoneyAmountSum healthsPartValues = healthsPartResult.Value; MoneyAmountSum socialsPartValues = socialsPartResult.Value; return(new EvaluateSource { // PROPERTIES SET GeneralBaseAmount = generalBaseValues.Balance(), HealthsPartAmount = healthsPartValues.Balance(), SocialsPartAmount = socialsPartValues.Balance(), // PROPERTIES SET }); }
public override EvaluateSource GetNewValues(EvaluateSource initValues) { ConfigCode workCode = (ConfigCode)ArticleCodeCz.FACT_POSITION_SCHEDULE; Result <MonthScheduleValue, string> workFindResult = InternalValues .FindResultValue <ArticleGeneralResult, MonthScheduleValue>( TargetFilters.TargetCodePlusPartFunc(workCode, InternalTarget.Head(), InternalTarget.Part()), (x) => (x.IsRealMonthValue())); MonthScheduleValue workValuesPrep = workFindResult.Value; ConfigCode termCode = (ConfigCode)ArticleCodeCz.FACT_POSITION_TERM; Result <MonthFromStopValue, string> termFindResult = InternalValues .FindResultValue <ArticleGeneralResult, MonthFromStopValue>( TargetFilters.TargetCodePlusHeadAndSeedFunc(termCode, InternalTarget.Head(), InternalTarget.Part()), (x) => (x.IsMonthFromStopValue())); if (ResultMonadUtils.HaveAnyResultFailed(workFindResult, workFindResult)) { return(ReturnFailureAndError(initValues, ResultMonadUtils.FirstFailedResultError(workFindResult, workFindResult))); } MonthFromStopValue termValuesPrep = termFindResult.Value; return(new EvaluateSource { // PROPERTIES SET DayTermFrom = termValuesPrep.PeriodDayFrom, DayTermStop = termValuesPrep.PeriodDayStop, RealMonthHours = workValuesPrep.HoursMonth, // PROPERTIES SET }); }
public override EvaluateSource GetNewValues(EvaluateSource initValues) { ConfigCode declaracyCode = (ConfigCode)ArticleCodeCz.FACT_INS_DECLARATION_SOCIAL; Result <DeclarationSocialValue, string> declaracyResult = InternalValues .FindResultValue <ArticleGeneralResult, DeclarationSocialValue>( TargetFilters.TargetCodePlusHeadAndNullPartFunc(declaracyCode, InternalTarget.Head()), (x) => (x.IsDeclarationSocialValue())); Result <MoneyPaymentSum, string> includeIncome = GetIncludeIncome(InternalValues, InternalTarget); Result <MoneyPaymentSum, string> excludeIncome = GetExcludeIncome(InternalValues, InternalTarget); if (ResultMonadUtils.HaveAnyResultFailed(declaracyResult, includeIncome, excludeIncome)) { return(ReturnFailureAndError(initValues, ResultMonadUtils.FirstFailedResultError(declaracyResult, includeIncome, excludeIncome))); } DeclarationSocialValue declaracyValues = declaracyResult.Value; MoneyPaymentSum includeValues = includeIncome.Value; MoneyPaymentSum excludeValues = excludeIncome.Value; return(new EvaluateSource { // PROPERTIES SET SummarizeType = declaracyValues.SummarizeType, IncludeIncome = includeValues.Balance(), ExcludeIncome = excludeValues.Balance(), // PROPERTIES SET }); }
public static Result <IEnumerable <PositionScheduleEvalDetail>, string> GetPositionValues(IEnumerable <ResultPair> results, ConfigCode termCode, ConfigCode dataCode, TargetHead headCode) { Result <IEnumerable <ResultPair>, string> termList = results .GetTypedResultsInListAndError <ArticleGeneralResult>( TargetFilters.TargetCodePlusHeadFunc(termCode, headCode)); Result <IEnumerable <ResultPair>, string> dataList = results .GetTypedResultsInListAndError <ArticleGeneralResult>( TargetFilters.TargetCodePlusHeadFunc(dataCode, headCode)); if (ResultMonadUtils.HaveAnyResultFailed(termList, dataList)) { return(Result.Fail <IEnumerable <PositionScheduleEvalDetail>, string>( ResultMonadUtils.FirstFailedResultError(termList, dataList))); } var zipsList = GetZip2Position(termList.Value, dataList.Value); if (zipsList.IsFailure) { return(Result.Fail <IEnumerable <PositionScheduleEvalDetail>, string>(zipsList.Error)); } var valsList = zipsList.Value.Select((tp) => (BuildItem(tp.Key, tp.Value.Item1, tp.Value.Item2))).ToList(); return(valsList.ToResultWithValueListAndError((tp) => (tp))); }
public override EvaluateSource GetNewValues(EvaluateSource initValues) { ConfigCode scheduleCode = (ConfigCode)ArticleCodeCz.FACT_POSITION_TIMESHEET; ConfigCode absencesCode = (ConfigCode)ArticleCodeCz.FACT_POSITION_ABSENCE; Result <MonthScheduleValue, string> scheduleResult = InternalValues .FindResultValue <ArticleGeneralResult, MonthScheduleValue>( TargetFilters.TargetCodePlusPartFunc(scheduleCode, InternalTarget.Head(), InternalTarget.Part()), (x) => (x.IsTermMonthValue())); Result <MonthScheduleValue, string> absencesResult = InternalValues .FindResultValue <ArticleGeneralResult, MonthScheduleValue>( TargetFilters.TargetCodePlusPartFunc(absencesCode, InternalTarget.Head(), InternalTarget.Part()), (x) => (x.IsTermMonthValue())); if (ResultMonadUtils.HaveAnyResultFailed(scheduleResult, absencesResult)) { return(ReturnFailureAndError(initValues, ResultMonadUtils.FirstFailedResultError(scheduleResult, absencesResult))); } MonthScheduleValue scheduleValues = scheduleResult.Value; MonthScheduleValue absencesValues = absencesResult.Value; return(new EvaluateSource { // PROPERTIES SET ScheduleMonth = scheduleValues.HoursMonth, AbsencesMonth = absencesValues.HoursMonth, // PROPERTIES SET }); }
private Result <IEnumerable <PositionEvaluateSource>, string> GetPositionValues() { ConfigCode positionCode = (ConfigCode)ArticleCodeCz.FACT_POSITION_TERM; ConfigCode scheduleCode = (ConfigCode)ArticleCodeCz.FACT_POSITION_TIMESHEET; Result <IEnumerable <ResultPair>, string> positionList = InternalValues .GetTypedResultsInListAndError <ArticleGeneralResult>( TargetFilters.TargetCodePlusHeadFunc(positionCode, InternalTarget.Head())); Result <IEnumerable <ResultPair>, string> scheduleList = InternalValues .GetTypedResultsInListAndError <ArticleGeneralResult>( TargetFilters.TargetCodePlusHeadFunc(scheduleCode, InternalTarget.Head())); if (ResultMonadUtils.HaveAnyResultFailed(positionList, scheduleList)) { return(Result.Fail <IEnumerable <PositionEvaluateSource>, string>( ResultMonadUtils.FirstFailedResultError(positionList, scheduleList))); } var positionZips = GetZip2Position(positionList.Value, scheduleList.Value); if (positionZips.IsFailure) { return(Result.Fail <IEnumerable <PositionEvaluateSource>, string>(positionZips.Error)); } var positionStream = positionZips.Value.Select((tp) => (BuildItem(tp.Key, tp.Value.Item1, tp.Value.Item2))).ToList(); return(positionStream.ToResultWithValueListAndError((tp) => (tp))); }
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 }); }
private static Result <IEnumerable <KeyValuePair <TargetPart, Tuple <ResultItem, ResultItem> > >, string> GetZip2Position(IEnumerable <ResultPair> positionList, IEnumerable <ResultPair> scheduleList) { Func <Result <ResultItem, string> > defaultTerm = () => (Result.Fail <ResultItem, string>(RESULT_DETAILS_INVALID_TERM)); Func <Result <ResultItem, string> > defaultData = () => (Result.Fail <ResultItem, string>(RESULT_DETAILS_INVALID_DATA)); Func <TargetItem, TargetItem, TargetPart> indexBuilder = (xa, xb) => (xb.Part()); Func <TargetItem, TargetItem, int> compareTarget = (xa, xb) => (xa.Seed().CompareTo(xb.Part())); var positionZips = ResultMonadUtils.Zip2ToResultWithKeyValListAndError(positionList, scheduleList, defaultTerm, defaultData, indexBuilder, compareTarget); return(positionZips); }
private Result <IEnumerable <KeyValuePair <TargetPart, Tuple <ResultItem, ResultItem> > >, string> GetZip2Position(IEnumerable <ResultPair> positionList, IEnumerable <ResultPair> scheduleList) { Func <Result <ResultItem, string> > defaultPosition = () => (Result.Fail <ResultItem, string>("position missing")); Func <Result <ResultItem, string> > defaultSchedule = () => (Result.Fail <ResultItem, string>("schedule missing")); Func <TargetItem, TargetItem, TargetPart> indexBuilder = (xa, xb) => (xb.Part()); Func <TargetItem, TargetItem, int> compareTarget = (xa, xb) => (xa.Seed().CompareTo(xb.Part())); var positionZips = ResultMonadUtils.Zip2ToResultWithKeyValListAndError(positionList, scheduleList, defaultPosition, defaultSchedule, indexBuilder, compareTarget); return(positionZips); }
public override EvaluateSource GetNewValues(EvaluateSource initValues) { ConfigCode declaracyCode = (ConfigCode)ArticleCodeCz.FACT_TAX_DECLARATION; ConfigCode participyCode = (ConfigCode)ArticleCodeCz.FACT_INS_DECLARATION_HEALTH; Result <DeclarationTaxingValue, string> declaracyResult = InternalValues .FindResultValue <ArticleGeneralResult, DeclarationTaxingValue>( TargetFilters.TargetCodePlusHeadAndNullPartFunc(declaracyCode, InternalTarget.Head()), (x) => (x.IsDeclarationTaxingValue())); Result <DeclarationHealthValue, string> participyResult = InternalValues .FindResultValue <ArticleGeneralResult, DeclarationHealthValue>( TargetFilters.TargetCodePlusHeadAndNullPartFunc(participyCode, InternalTarget.Head()), (x) => (x.IsDeclarationHealthValue())); Result <MoneyPaymentSum, string> taxableIncome = GetTaxableIncome(InternalValues, InternalTarget); Result <MoneyPaymentSum, string> partnerIncome = GetPartnerIncome(InternalValues, InternalTarget); Result <MoneyPaymentSum, string> excludeIncome = GetExcludeIncome(InternalValues, InternalTarget); if (ResultMonadUtils.HaveAnyResultFailed(declaracyResult, participyResult, taxableIncome, partnerIncome)) { return(ReturnFailureAndError(initValues, ResultMonadUtils.FirstFailedResultError(declaracyResult, participyResult, taxableIncome, partnerIncome))); } DeclarationTaxingValue declaracyValues = declaracyResult.Value; DeclarationHealthValue participyValues = participyResult.Value; MoneyPaymentSum taxableValues = taxableIncome.Value; MoneyPaymentSum partnerValues = partnerIncome.Value; MoneyPaymentSum excludeValues = excludeIncome.Value; return(new EvaluateSource { // PROPERTIES SET SummarizeType = declaracyValues.SummarizeType, StatementType = declaracyValues.StatementType, DeclaracyType = declaracyValues.DeclaracyType, ResidencyType = declaracyValues.ResidencyType, TaxableIncome = taxableValues.Balance(), PartnerIncome = partnerValues.Balance(), ExcludeIncome = excludeValues.Balance(), // PROPERTIES SET }); }
public override EvaluateSource GetNewValues(EvaluateSource initValues) { Result <MoneyAmountSum, string> taxableIncome = GetTaxableIncome(InternalValues, InternalTarget); if (ResultMonadUtils.HaveAnyResultFailed(taxableIncome)) { return(ReturnFailureAndError(initValues, taxableIncome.Error)); } MoneyAmountSum taxableValues = taxableIncome.Value; return(new EvaluateSource { // PROPERTIES SET IncomeWithhold = taxableValues.Balance(), // PROPERTIES SET }); }
public override EvaluateSource GetNewValues(EvaluateSource initValues) { Result <TaxableIncomeSum, string> taxableIncome = GetTaxableIncome(InternalValues, InternalTarget); if (ResultMonadUtils.HaveAnyResultFailed(taxableIncome)) { return(ReturnFailureAndError(initValues, taxableIncome.Error)); } TaxableIncomeSum taxableValues = taxableIncome.Value; return(new EvaluateSource { // PROPERTIES SET GeneralIncome = taxableValues.IncomeGeneral(), ExcludeIncome = taxableValues.IncomeExclude(), LolevelIncome = taxableValues.IncomeLolevel(), TaskAgrIncome = taxableValues.IncomeTaskAgr(), PartnerIncome = taxableValues.IncomePartner(), // PROPERTIES SET }); }