private decimal InnerComputeResultValue(PayTagGateway tagConfig, uint tagCode, KeyValuePair <TagRefer, PayrollResult> result)
        {
            TagRefer      resultKey  = result.Key;
            PayrollResult resultItem = result.Value;

            return(SumTermFor(tagConfig, tagCode, resultKey, resultItem));
        }
Esempio n. 2
0
        // create pair of TagRefer and PayrollConcept with code order
        private KeyValuePair <TagRefer, PayrollConcept> NewTermPairWithOrder(uint periodBase, CodeNameRefer termRefer, uint codeOrder, IDictionary <string, object> termValues)
        {
            TagRefer       termKey     = NewTermKeyWithOrder(periodBase, termRefer, codeOrder);
            PayrollConcept termConcept = NewTermConcept(termRefer, termValues);

            return(new KeyValuePair <TagRefer, PayrollConcept>(termKey, termConcept));
        }
Esempio n. 3
0
        private KeyValuePair <TagRefer, PayrollConcept> NewTermPair(IDictionary <TagRefer, PayrollConcept> termHash, uint periodBase, CodeNameRefer termRefer, IDictionary <string, object> termValues)
        {
            uint           newCodeOrder = GetNewTagOrderFrom(termHash, periodBase, termRefer.Code);
            TagRefer       termKey      = NewTermKeyWithOrder(periodBase, termRefer, newCodeOrder);
            PayrollConcept termConcept  = NewTermConcept(termRefer, termValues);

            return(new KeyValuePair <TagRefer, PayrollConcept>(termKey, termConcept));
        }
 public PayrollTag[] CollectPendingCodesForFunc(TagRefer termRefer, PayrollConcept termConcept)
 {
     PayrollTag[] termPendingCodes = termConcept.TagPendingCodes;
     if (termPendingCodes == null)
     {
         return(new PayrollTag[0]);
     }
     else
     {
         return((PayrollTag[])termPendingCodes.Clone());
     }
 }
Esempio n. 5
0
        public void test_base_salary()
        {
            CodeNameRefer tagCodeName = PayTagGateway.REF_SALARY_BASE;
            var           values      = new Dictionary <string, object>()
            {
                { "amount_monthly", 15000m }
            };
            TagRefer payTag = PayProcess.AddTerm(tagCodeName, values);
            var      payTer = PayProcess.GetTerm(payTag);

            Assert.AreEqual(15000m, ((SalaryMonthlyConcept)payTer[payTag]).AmountMonthly);
        }
Esempio n. 6
0
        public void test_working_schedule()
        {
            CodeNameRefer tagCodeName = PayTagGateway.REF_SCHEDULE_WORK;
            var           values      = new Dictionary <string, object>()
            {
                { "hours_weekly", 40 }
            };
            TagRefer payTag = PayProcess.AddTerm(tagCodeName, values);
            var      payTer = PayProcess.GetTerm(payTag);

            Assert.AreEqual(40, ((ScheduleWeeklyConcept)payTer[payTag]).HoursWeekly);
        }
        private decimal SumTermFor(PayTagGateway tagConfig, uint tagCode, TagRefer resultKey, PayrollResult resultItem)
        {
            var tagConfigItem = tagConfig.FindTag(resultKey.Code);

            if (resultItem.SummaryFor(tagCode))
            {
                if (tagConfigItem.InsuranceHealth())
                {
                    return(resultItem.Payment());
                }
            }
            return(decimal.Zero);
        }
Esempio n. 8
0
        // evaluate and return result from Results by key of tag
        public IDictionary <TagRefer, PayrollResult> Evaluate(TagRefer payTag)
        {
            uint periodBase = PayrollPeriod.NOW;

            PayrollTag[] pendingUniqCodes = Concepts.CollectPendingCodesFor(Terms);

            var calculationSteps = CreateCalculationSteps(Terms, periodBase, pendingUniqCodes);

            var sortedCalculation = calculationSteps.OrderBy(x => (x.Value));

            this.Results = sortedCalculation.Aggregate(new Dictionary <TagRefer, PayrollResult>(),
                                                       (agr, x) => (agr.Union(new Dictionary <TagRefer, PayrollResult>()
            {
                { x.Key, x.Value.Evaluate(Period, Tags, agr) }
            }).ToDictionary(key => key.Key, value => value.Value)));
            return(GetResult(payTag));
        }
Esempio n. 9
0
        private decimal SumTermFor(PayTagGateway tagConfig, uint tagCode, TagRefer resultKey, PayrollResult resultItem)
        {
            var tagConfigItem = tagConfig.FindTag(resultKey.Code);

            if (resultItem.SummaryFor(tagCode))
            {
                if (tagConfigItem.IncomeNetto())
                {
                    return(resultItem.Payment());
                }
                else
                if (tagConfigItem.DeductionNetto())
                {
                    return(decimal.Negate(resultItem.Payment()));
                }
            }
            return(decimal.Zero);
        }
        public void test_insert_CodeOrder_6_at_end()
        {
            uint          period      = PayrollPeriod.NOW;
            CodeNameRefer tagCodeName = PayTagGateway.REF_SALARY_BASE;
            var           values1     = new Dictionary <string, object>()
            {
                { "amount_monthly", 1000 }
            };
            var values2 = new Dictionary <string, object>()
            {
                { "amount_monthly", 2000 }
            };
            var values3 = new Dictionary <string, object>()
            {
                { "amount_monthly", 3000 }
            };
            var values4 = new Dictionary <string, object>()
            {
                { "amount_monthly", 4000 }
            };
            var values5 = new Dictionary <string, object>()
            {
                { "amount_monthly", 5000 }
            };

            PayProcess.InsTerm(period, tagCodeName, 3, values3);
            PayProcess.InsTerm(period, tagCodeName, 5, values5);
            PayProcess.InsTerm(period, tagCodeName, 1, values1);
            PayProcess.InsTerm(period, tagCodeName, 4, values4);
            PayProcess.InsTerm(period, tagCodeName, 2, values2);
            var valuesI = new Dictionary <string, object>()
            {
                { "amount_monthly", 15000 }
            };
            TagRefer payTag = PayProcess.AddTerm(tagCodeName, valuesI);

            Assert.AreEqual((uint)6, payTag.CodeOrder);
        }
Esempio n. 11
0
        void TestPayrollProcessWithSpec(IDictionary <string, object> specs, IDictionary <string, object> results)
        {
            var EMPTY_VALUES = new Dictionary <string, object>()
            {
            };

            var    testSpec            = specs;
            string testSpecName        = S_GET_FROM(testSpec, "name");
            var    schedule_work_value = I_MAKE_HASH("hours_weekly", I_GET_FROM(testSpec, "schedule"));
            var    schedule_term_value = new Dictionary <string, object>()
            {
                { "date_from", null }, { "date_end", null }
            };

            PayProcess.AddTerm(REF_SCHEDULE_WORK, schedule_work_value);
            PayProcess.AddTerm(REF_SCHEDULE_TERM, schedule_term_value);
            var absence_hours_value = I_MAKE_HASH("hours", I_GET_FROM(testSpec, "absence"));

            PayProcess.AddTerm(REF_HOURS_ABSENCE, absence_hours_value);
            var salary_amount_value = D_MAKE_HASH(@"amount_monthly", D_GET_FROM(testSpec, @"salary"));

            PayProcess.AddTerm(REF_SALARY_BASE, salary_amount_value);
            uint yes_no1         = U_GET_FROM(testSpec, @"tax payer");
            uint tax_interest    = yes_no1 != 0 ? 1u : 0u;
            uint tax_declare     = yes_no1 == 3 ? 1u : 0u;
            var  interest_value1 = new Dictionary <string, object>()
            {
                { "interest_code", tax_interest },
                { "declare_code", tax_declare }
            };

            PayProcess.AddTerm(REF_TAX_INCOME_BASE, interest_value1);
            uint yes_no2         = U_GET_FROM(testSpec, "health payer");
            uint minim           = U_GET_FROM(testSpec, "health minim");
            var  interest_value2 = new Dictionary <string, object>()
            {
                { "interest_code", yes_no2 },
                { "minimum_asses", minim }
            };

            PayProcess.AddTerm(REF_INSURANCE_HEALTH_BASE, interest_value2);
            PayProcess.AddTerm(REF_INSURANCE_HEALTH, interest_value2);
            uint yes_no3         = U_GET_FROM(testSpec, "social payer");
            var  interest_value3 = U_MAKE_HASH("interest_code", yes_no3);

            PayProcess.AddTerm(REF_INSURANCE_SOCIAL_BASE, interest_value3);
            PayProcess.AddTerm(REF_INSURANCE_SOCIAL, interest_value3);
            uint yes_no4         = U_GET_FROM(testSpec, "pension payer");
            var  interest_value4 = I_MAKE_HASH("interest_code", yes_no4);

            PayProcess.AddTerm(REF_SAVINGS_PENSIONS, interest_value4);
            uint yes_no5       = U_GET_FROM(testSpec, "tax payer benefit");
            var  relief_value1 = U_MAKE_HASH("relief_code", yes_no5);

            PayProcess.AddTerm(REF_TAX_CLAIM_PAYER, relief_value1);
            uint count         = U_GET_FROM(testSpec, "tax child benefit");
            var  relief_value2 = U_MAKE_HASH("relief_code", 1u);

            for (int i = 0; i < count; i++)
            {
                PayProcess.AddTerm(REF_TAX_CLAIM_CHILD, relief_value2);
            }
            uint yes_no6       = U_GET_FROM(testSpec, "tax disability benefit");
            var  relief_value3 = new Dictionary <string, object>()
            {
                { "relief_code_1", (yes_no6 % 10) },
                { "relief_code_2", ((yes_no6 / 10) % 10) },
                { "relief_code_3", ((yes_no6 / 100) % 10) }
            };

            PayProcess.AddTerm(REF_TAX_CLAIM_DISABILITY, relief_value3);
            uint yes_no7       = U_GET_FROM(testSpec, "tax studying benefit");
            var  relief_value4 = U_MAKE_HASH("relief_code", yes_no7);

            PayProcess.AddTerm(REF_TAX_CLAIM_STUDYING, relief_value4);
            uint yes_no8         = U_GET_FROM(testSpec, "health employer");
            var  interest_value5 = U_MAKE_HASH("interest_code", yes_no8);

            PayProcess.AddTerm(REF_TAX_EMPLOYERS_HEALTH, interest_value5);
            uint yes_no9         = U_GET_FROM(testSpec, "social employer");
            var  interest_value6 = U_MAKE_HASH("interest_code", yes_no9);

            PayProcess.AddTerm(REF_TAX_EMPLOYERS_SOCIAL, interest_value6);

            PayProcess.AddTerm(REF_INCOME_GROSS, EMPTY_VALUES);
            TagRefer evResultTermTag = PayProcess.AddTerm(REF_INCOME_NETTO, EMPTY_VALUES);
            var      evResultDictVal = PayProcess.Evaluate(evResultTermTag);

            var      testResults = results;
            TagRefer resultTag   = new TagRefer(PayrollPeriod.NOW, (uint)TagCode.TAG_INCOME_NETTO, 1u);
            decimal  result01    = D_GET_FROM(testResults, @"tax income");
            decimal  result02    = D_GET_FROM(testResults, @"premium insurance");
            decimal  result03    = D_GET_FROM(testResults, @"tax base");
            decimal  result04    = D_GET_FROM(testResults, @"health base");
            decimal  result05    = D_GET_FROM(testResults, @"social base");
            decimal  result06    = D_GET_FROM(testResults, @"health ins");
            decimal  result07    = D_GET_FROM(testResults, @"social ins");
            decimal  result08    = D_GET_FROM(testResults, @"tax before");
            decimal  result09    = D_GET_FROM(testResults, @"payer relief");
            decimal  result10    = D_GET_FROM(testResults, @"tax after A relief");
            decimal  result11    = D_GET_FROM(testResults, @"child relief");
            decimal  result12    = D_GET_FROM(testResults, @"tax after C relief");
            decimal  result13    = D_GET_FROM(testResults, @"tax advance");
            decimal  result14    = D_GET_FROM(testResults, @"tax bonus");
            decimal  result15    = D_GET_FROM(testResults, @"gross income");
            decimal  result16    = D_GET_FROM(testResults, @"netto income");

            decimal testVal01  = GetResultIncomeBase(REF_TAX_INCOME_BASE);
            decimal testVal02a = GetResultPayment(REF_TAX_EMPLOYERS_HEALTH);
            decimal testVal02b = GetResultPayment(REF_TAX_EMPLOYERS_SOCIAL);
            decimal testVal03  = GetResultIncomeBase(REF_TAX_ADVANCE_BASE);
            decimal testVal03w = GetResultIncomeBase(REF_TAX_WITHHOLD_BASE);
            decimal testVal04  = GetResultEmployeeBase(REF_INSURANCE_HEALTH_BASE);
            decimal testVal05  = GetResultEmployeeBase(REF_INSURANCE_SOCIAL_BASE);
            decimal testVal06  = GetResultPayment(REF_INSURANCE_HEALTH);
            decimal testVal07  = GetResultPayment(REF_INSURANCE_SOCIAL);
            decimal testVal08  = GetResultPayment(REF_TAX_ADVANCE);
            decimal testVal09  = GetResultTaxRelief(REF_TAX_RELIEF_PAYER);
            decimal testVal10  = GetResultAfterReliefA(REF_TAX_ADVANCE_FINAL);
            decimal testVal11  = GetResultTaxRelief(REF_TAX_RELIEF_CHILD);
            decimal testVal12  = GetResultAfterReliefC(REF_TAX_ADVANCE_FINAL);
            decimal testVal13  = GetResultPayment(REF_TAX_ADVANCE_FINAL);
            decimal testVal14  = GetResultPayment(REF_TAX_BONUS_CHILD);
            decimal testVal15  = GetResultAmount(REF_INCOME_GROSS);
            decimal testVal16  = GetResultAmount(REF_INCOME_NETTO);
            decimal testVal02  = decimal.Add(testVal02a, testVal02b);

            Assert.AreEqual(testVal01, result01, @"tax income         should be {0} CZK, NOT {1}!", result01, testVal01);
            Assert.AreEqual(testVal02, result02, @"premium insurance  should be {0} CZK, NOT {1}!", result02, testVal02);
            Assert.AreEqual(testVal03, result03, @"tax base           should be {0} CZK, NOT {1}!", result03, testVal03);
            Assert.AreEqual(testVal04, result04, @"health base        should be {0} CZK, NOT {1}!", result04, testVal04);
            Assert.AreEqual(testVal05, result05, @"social base        should be {0} CZK, NOT {1}!", result05, testVal05);
            Assert.AreEqual(testVal06, result06, @"health ins         should be {0} CZK, NOT {1}!", result06, testVal06);
            Assert.AreEqual(testVal07, result07, @"social ins         should be {0} CZK, NOT {1}!", result07, testVal07);
            Assert.AreEqual(testVal08, result08, @"tax before         should be {0} CZK, NOT {1}!", result08, testVal08);
            Assert.AreEqual(testVal09, result09, @"payer relief       should be {0} CZK, NOT {1}!", result09, testVal09);
            Assert.AreEqual(testVal10, result10, @"tax after A relief should be {0} CZK, NOT {1}!", result10, testVal10);
            Assert.AreEqual(testVal11, result11, @"child relief       should be {0} CZK, NOT {1}!", result11, testVal11);
            Assert.AreEqual(testVal12, result12, @"tax after C relief should be {0} CZK, NOT {1}!", result12, testVal12);
            Assert.AreEqual(testVal13, result13, @"tax advance        should be {0} CZK, NOT {1}!", result13, testVal13);
            Assert.AreEqual(testVal14, result14, @"tax bonus          should be {0} CZK, NOT {1}!", result14, testVal14);
            Assert.AreEqual(testVal15, result15, @"gross income       should be {0} CZK, NOT {1}!", result15, testVal15);
            Assert.AreEqual(testVal16, result16, @"netto income       should be {0} CZK, NOT {1}!", result16, testVal16);
        }
Esempio n. 12
0
        private TagRefer NewTermKeyWithOrder(uint periodBase, CodeNameRefer termRefer, uint codeOrder)
        {
            TagRefer termKey = new TagRefer(periodBase, termRefer.Code, codeOrder);

            return(termKey);
        }
Esempio n. 13
0
 // get term from Results by key of tag
 public IDictionary <TagRefer, PayrollResult> GetResult(TagRefer payTag)
 {
     return(Results.Where(tag => tag.Key == payTag).ToDictionary(key => key.Key, value => value.Value));
 }
Esempio n. 14
0
 // get term from Terms by key of tag
 public IDictionary <TagRefer, PayrollConcept> GetTerm(TagRefer payTag)
 {
     return(Terms.Where(tag => tag.Key == payTag).ToDictionary(key => key.Key, value => value.Value));
 }