public void InputSuperRate(PayDetails payDetails) { try { System.Console.WriteLine("Please enter your super rate:"); string inputSuperRate; var promptUserFormat = false; do { inputSuperRate = System.Console.ReadLine(); promptUserFormat = !payDetails.TrySetSuperRate(inputSuperRate); if (promptUserFormat) { System.Console.WriteLine("Wrong format, the super rate should be numbers only, please re-enter your super rate:"); } else { System.Console.WriteLine("You entered super rate: " + payDetails.SuperRate); } } while (promptUserFormat); // while (regexSalary.IsMatch(inputRate) == false){ // Console.WriteLine("Wrong format, the super rate should be numbers only, please re-enter your super rate:"); // inputRate = Console.ReadLine(); // } // payDetails.Super = payDetails.CalcSuper(inputValue); } catch (Exception e) { throw e; } }
public PayDetailsRequest.PayDetailsResponse CalculateTax(PayDetailsRequest request) { PayDetails payDetails = new PayDetails() { FirstName = request.FirstName, SurName = request.SurName, PayStartDate = request.PayStartDate, PayEndDate = request.PayEndDate }; bool isValueValid = payDetails.TrySetSuperRate(request.SuperRate) && payDetails.TrySetAnnualSalary(request.AnnualSalary); if (isValueValid) { return(new PayDetailsRequest.PayDetailsResponse( payDetails.PayPeriod, payDetails.FullName, payDetails.GrossIncome, payDetails.IncomeTax, payDetails.NetIncome, payDetails.Super, 200)); } // do we reject ? throw exception ? throw new exception /*TODO: map the methods in the payDetail object*/ // fill out response object from paydetails return(new PayDetailsRequest.PayDetailsResponse(422, "Invalid input values")); }
public void IncomeTax_ShouldPositiveIfNegative() { var salary = -40000; var super = 9.5; var payDetails = new PayDetails(); payDetails.TrySetAnnualSalary(salary.ToString()); payDetails.calcIncomeTax(); payDetails.TrySetSuperRate(super.ToString()); Assert.AreEqual(3333, payDetails.GrossIncome); Assert.AreEqual(379, payDetails.IncomeTax); Assert.AreEqual(2954, payDetails.NetIncome); Assert.AreEqual(316, payDetails.Super); }
public void IncomeTax_ShouldFallIntoFifthBracket() { var salary = 200000; var super = 9.5; var payDetails = new PayDetails(); payDetails.TrySetAnnualSalary(salary.ToString()); payDetails.calcIncomeTax(); payDetails.TrySetSuperRate(super.ToString()); Assert.AreEqual(16666, payDetails.GrossIncome); Assert.AreEqual(5270, payDetails.IncomeTax); Assert.AreEqual(11396, payDetails.NetIncome); Assert.AreEqual(1583, payDetails.Super); }
public void IncomeTax_ShouldFallIntoSecondBracket() { var salary = 23000; var super = 9.5; var payDetails = new PayDetails(); payDetails.TrySetAnnualSalary(salary.ToString()); payDetails.calcIncomeTax(); payDetails.TrySetSuperRate(super.ToString()); Assert.AreEqual(1916, payDetails.GrossIncome); Assert.AreEqual(76, payDetails.IncomeTax); Assert.AreEqual(1840, payDetails.NetIncome); Assert.AreEqual(182, payDetails.Super); }
public void IncomeTax_ShouldFallInTheMiddleBracket_IfSalaryExactlyEqualsBracketMinimum() { var salary = 87000.5; var super = 9.5; var payDetails = new PayDetails(); payDetails.TrySetAnnualSalary(salary.ToString()); payDetails.calcIncomeTax(); payDetails.TrySetSuperRate(super.ToString()); Assert.AreEqual(7250, payDetails.GrossIncome); Assert.AreEqual(1652, payDetails.IncomeTax); Assert.AreEqual(5598, payDetails.NetIncome); Assert.AreEqual(688, payDetails.Super); }
[Test] public void IncomeTax_ShouldFallInTheLastBracket_IfSalaryExactlyEqualsBracketMinimum() { var salary = 180000.5; var super = 9.5; var payDetails = new PayDetails(); payDetails.TrySetAnnualSalary(salary.ToString()); payDetails.calcIncomeTax(); payDetails.TrySetSuperRate(super.ToString()); Assert.AreEqual(15000, payDetails.GrossIncome); Assert.AreEqual(4520, payDetails.IncomeTax); Assert.AreEqual(10480, payDetails.NetIncome); Assert.AreEqual(1425, payDetails.Super); }
public void IncomeTax_ShouldFallIntoFirstBracket() { var salary = 17000; var super = 9; var payDetails = new PayDetails(); payDetails.TrySetAnnualSalary(salary.ToString()); payDetails.calcIncomeTax(); payDetails.TrySetSuperRate(super.ToString()); Assert.AreEqual(1416, payDetails.GrossIncome); Assert.AreEqual(0, payDetails.IncomeTax); Assert.AreEqual(1416, payDetails.NetIncome); Assert.AreEqual(127, payDetails.Super); }
public void IncomeTax_SuperRateShouldBePositiveIfNegative() { var salary = 50000; var super = -9.5; var payDetails = new PayDetails(); payDetails.TrySetAnnualSalary(salary.ToString()); payDetails.calcIncomeTax(); payDetails.TrySetSuperRate(super.ToString()); Assert.AreEqual(4166, payDetails.GrossIncome); Assert.AreEqual(650, payDetails.IncomeTax); Assert.AreEqual(3516, payDetails.NetIncome); Assert.AreEqual(395, payDetails.Super); }
public void IncomeTax_ShouldBeZeroIfZero() { var salary = 0; var super = 9.5; var payDetails = new PayDetails(); payDetails.TrySetAnnualSalary(salary.ToString()); payDetails.calcIncomeTax(); payDetails.TrySetSuperRate(super.ToString()); Assert.AreEqual(0, payDetails.GrossIncome); Assert.AreEqual(0, payDetails.IncomeTax); Assert.AreEqual(0, payDetails.NetIncome); Assert.AreEqual(0, payDetails.Super); }