Ejemplo n.º 1
0
        public decimal GetAllowance(TaxCalculatorCommand model)
        {
            decimal allowance = 0;

            //1
            allowance += PersonlAllowance(model.ApplyWithSpouse);
            //2
            if (!model.ApplyWithSpouse)
            {
                allowance += SpouseAllowance(model.IsMarried, model.IsSpouseEligible);
            }
            //3
            allowance += ChildAllowance(model.EligibleChildBefore2561, model.EligibleChildAfter2561, model.EligibleAdoptedChild);
            //4
            allowance += ParentalCareAllowance(model.IsMarried, model.OwnParent, model.SpouseParent);
            //5
            allowance += DisabledCareAllowance(model.HasNonFamilyDisable, model.InFamilyDisable);
            //6, 7.1, 7.2
            allowance += InsuranceAllowance(model.ParentalInsurance, model.LifeInsurance, model.HealthInsurance);
            //8
            allowance += ProvFundAllowance(model.ProvFund);
            //9
            allowance += SavingFundAllowance(model.SavingFund);
            //11
            allowance += LTFAllowance(model.LTF, model.TotalIncome);
            //10
            allowance += InvestmentPackageAllowance(model.RMF, model.GPF, model.ProvFund, model.SavingFund, model.TeacherFund, model.PensionInsurance, model.TotalIncome);
            //13
            allowance += RealEstateAllowance(model.RealEstatePrice, model.HouseYearBuy);
            //19
            allowance += model.MaternityAllowance;
            //12, 14, 17, 18, 15, 20, 21
            allowance += OtherExpense(model.HousingInterest, model.SocialSecurity, model.TravelExpense, model.StartupInvestment, model.CctvExpense, model.PoliticalParty, model.OtherExpense);
            return(allowance);
        }
Ejemplo n.º 2
0
        [TestCase(30, 0, false, 300, 500000, 0, 1000, 450)]                       // LeaveCompensate + MaxProvFund at 15% of Income
        public void Test_Engine_GetExemption(
            int age, decimal gPF, bool isDisabled, decimal leaveCompensate, decimal provFund, decimal teacherFund, decimal totalIncome, decimal expectedResult)
        {
            TaxCalculatorCommand exemption = new TaxCalculatorCommand()
            {
                Age = age, GPF = gPF, IsDisabled = isDisabled, LeaveCompensate = leaveCompensate, ProvFund = provFund, TeacherFund = teacherFund, TotalIncome = totalIncome
            };
            var result = engine.GetExemption(exemption);

            Assert.AreEqual(expectedResult, result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// คำนวนภาษี
        /// </summary>
        /// <param name="inputCommand"></param>
        /// <returns>ภาษีที่ต้องจ่ายแยกตามข้อ ก 1 - 12</returns>
        public TaxResultModel TaxCalculator(TaxCalculatorCommand inputCommand)
        {
            TaxCalculatorCommand command = inputCommand;
            TaxResultModel       result  = new TaxResultModel();

            result.A1  = command.TotalIncome;
            result.A2  = GetExemption(command);
            result.A3  = result.A1 - result.A2;
            result.A4  = GetPersonalExpenseExemption(command.TotalIncome);
            result.A5  = result.A3 - result.A4;
            result.A6  = GetAllowance(command);
            result.A7  = result.A5 - result.A6;
            result.A8  = EducationDonation(command.EducationDonation, result.A7);
            result.A9  = result.A7 - result.A8;
            result.A10 = OtherDonation(command.OtherDonation, result.A9);
            result.A11 = result.A9 - result.A10;
            result.A12 = StairCaseTax(result.A11);
            return(result);
        }
Ejemplo n.º 4
0
        public decimal GetExemption(TaxCalculatorCommand exem)
        {
            TaxCalculatorCommand exemption = exem;
            decimal exempt = 0;

            exemption.TeacherFund = SetLimit(exemption.TeacherFund, 500000);
            exempt += exemption.TeacherFund;

            decimal provFund = 0;

            if (exemption.ProvFund > 10000)
            {
                if (exemption.ProvFund > 500000)
                {
                    provFund = 490000;
                }
                else
                {
                    provFund = exemption.ProvFund - 10000;
                }

                provFund = SetLimit(provFund, exemption.TotalIncome * 0.15m);

                exempt += provFund;
            }

            exemption.GPF = SetLimit(exemption.GPF, 500000);
            exempt       += exemption.GPF;

            exempt = SetLimit(exempt, 500000);

            if (exemption.IsDisabled || exemption.Age >= 65)
            {
                exempt += 190000m;
            }

            exemption.LeaveCompensate = SetLimit(exemption.LeaveCompensate, 300000);
            exempt += exemption.LeaveCompensate;

            return(exempt);
        }
Ejemplo n.º 5
0
 public TaxCalculatorViewModel()
 {
     Model = new TaxCalculatorCommand
     {
         TotalIncome             = 5000000,
         IsDisabled              = false,
         Age                     = 30,
         TeacherFund             = 100000,
         ProvFund                = 100000,
         GPF                     = 100000,
         LeaveCompensate         = 0,
         ApplyWithSpouse         = false,
         IsMarried               = false,
         IsSpouseEligible        = false,
         EligibleChildBefore2561 = 1,
         EligibleAdoptedChild    = 1,
         EligibleChildAfter2561  = 1,
         OwnParent               = 2,
         SpouseParent            = 0,
         HasNonFamilyDisable     = false,
         InFamilyDisable         = 0,
         ParentalInsurance       = 15000,
         LifeInsurance           = 70000,
         HealthInsurance         = 15000,
         SavingFund              = 13200,
         LTF                     = 400000,
         RMF                     = 200000,
         PensionInsurance        = 20000,
         PoliticalParty          = 10000,
         TravelExpense           = 20000,
         SocialSecurity          = 9000,
         HousingInterest         = 100000,
         StartupInvestment       = 100000,
         CctvExpense             = 0,
         OtherExpense            = 9000,
         EducationDonation       = 0,
         OtherDonation           = 0
     };
     ResetValueCommand = new Command(GetTax);
 }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            Console.WriteLine("This is uTax - Tax Calculator");
            //TaxCalculatorCommand command = new TaxCalculatorCommand
            //{
            //    TotalIncome = 5000000,
            //    IsDisabled = false,
            //    Age = 30,
            //    TeacherFund = 100000,
            //    ProvFund = 100000,
            //    GPF = 100000,
            //    LeaveCompensate = 0,
            //    ApplyWithSpouse = false,
            //    IsMarried = false,
            //    IsSpouseEligible = false,
            //    EligibleChildBefore2561 = 1,
            //    EligibleAdoptedChild = 1,
            //    EligibleChildAfter2561 = 1,
            //    OwnParent = 2,
            //    SpouseParent = 0,
            //    HasNonFamilyDisable = false,
            //    InFamilyDisable = 0,
            //    ParentalInsurance = 15000,
            //    LifeInsurance = 70000,
            //    HealthInsurance = 15000,
            //    SavingFund = 13200,
            //    LTF = 400000,
            //    RMF = 200000,
            //    PensionInsurance = 20000,
            //    PoliticalParty = 10000,
            //    TravelExpense = 20000,
            //    SocialSecurity = 9000,
            //    HousingInterest = 100000,
            //    StartupInvestment = 100000,
            //    CctvExpense = 0,
            //    OtherExpense = 9000,
            //    EducationDonation = 0,
            //    OtherDonation = 0
            //};


            //TaxCalculatorCommand command = new TaxCalculatorCommand
            //{
            //    TotalIncome = 100000000,
            //    ProvFund = 600000,
            //    OwnParent = 2,
            //    InFamilyDisable = 1,
            //    LifeInsurance = 120000,
            //    HealthInsurance = 16000,
            //    LTF = 600000,
            //    RMF = 600000,
            //    TravelExpense = 60000,
            //    SocialSecurity = 9000,
            //    HousingInterest = 200000,
            //    StartupInvestment = 200000,
            //    OtherExpense = 40000,
            //    EducationDonation = 5000000,
            //    OtherDonation = 10000000,
            //    MaternityAllowance = 100000,
            //    RealEstatePrice = 4000000 // พังที่ Realestate ไม่ได้เช็ค เกิน 3000000
            //};

            TaxCalculatorCommand command = new TaxCalculatorCommand
            {
                TotalIncome = 100000000,
                //IsDisabled = false,
                //Age = 30,
                //TeacherFund = 100000,
                //ProvFund = 100000,
                //GPF = 100000,
                //LeaveCompensate = 0,
                //ApplyWithSpouse = false,
                //IsMarried = false,
                //IsSpouseEligible = false,
                //EligibleChildBefore2561 = 1,
                //EligibleAdoptedChild = 1,
                //EligibleChildAfter2561 = 1,
                //OwnParent = 2,
                //SpouseParent = 0,
                //HasNonFamilyDisable = false,
                //InFamilyDisable = 0,
                //ParentalInsurance = 15000,
                //LifeInsurance = 70000,
                //HealthInsurance = 15000,
                //SavingFund = 13200,
                //LTF = 400000,
                //RMF = 200000,
                //PensionInsurance = 20000,
                //PoliticalParty = 10000,
                //TravelExpense = 20000,
                //SocialSecurity = 9000,
                //HousingInterest = 100000,
                //StartupInvestment = 100000,
                //CctvExpense = 0,
                //OtherExpense = 9000,
                //EducationDonation = 0,
                //OtherDonation = 0
            };

            Console.WriteLine("สวัสดี");
            Engine engine = new Engine();
            var    result = engine.TaxCalculator(command);

            int i = 1;

            Console.WriteLine($"A{i}: {result.A1:n}"); i++;
            Console.WriteLine($"A{i}: {result.A2:n}"); i++;
            Console.WriteLine($"A{i}: {result.A3:n}"); i++;
            Console.WriteLine($"A{i}: {result.A4:n}"); i++;
            Console.WriteLine($"A{i}: {result.A5:n}"); i++;
            Console.WriteLine($"A{i}: {result.A6:n}"); i++;
            Console.WriteLine($"A{i}: {result.A7:n}"); i++;
            Console.WriteLine($"A{i}: {result.A8:n}"); i++;
            Console.WriteLine($"A{i}: {result.A9:n}"); i++;
            Console.WriteLine($"A{i}: {result.A10:n}"); i++;
            Console.WriteLine($"A{i}: {result.A11:n}"); i++;
            Console.WriteLine($"A{i}: {result.A12:n}"); i++;
        }
Ejemplo n.º 7
0
        public void Test_Engine_OverallTest(TaxCalculatorCommand model)
        {
            var result = engine.TaxCalculator(model);

            Assert.AreEqual(model.ExpectedResult, result.A12);
        }