示例#1
0
        public static void ProcessPayslipConsole()
        {
            Console.WriteLine("Welcome to the payslip generator!\r\n");

            _userInformationParser.PromptPayslipInformation(_userInputInformation);

            _payslipInformation = _payslipGenerator.GeneratePayslip(_userInputInformation);

            _payslipPresenter.PresentPayslipConsole(_payslipInformation);
        }
        public PayslipInformation GeneratePayslip(UserInputInformation userInputInformation)
        {
            PayslipInformation payslipInformation = new PayslipInformation();

            payslipInformation.Fullname = userInputInformation.Name + " " + userInputInformation.Surname;

            payslipInformation.GrossIncome = Convert.ToUInt32(Math.Round(userInputInformation.Salary / 12.0)); // Gross income is monthly, so divide by 12

            payslipInformation.IncomeTax = CalculateIncomeTax(payslipInformation.GrossIncome * 12);            // Income tax calculated on annual pay, then made monthly within method

            payslipInformation.NetIncome = payslipInformation.GrossIncome - payslipInformation.IncomeTax;

            payslipInformation.Super = checked ((uint)Math.Round(payslipInformation.GrossIncome * (userInputInformation.SuperRate / 100.0)));

            payslipInformation.PaymentStartDate = userInputInformation.PaymentStartDate;

            payslipInformation.PaymentEndDate = userInputInformation.PaymentEndDate;

            return(payslipInformation);
        }
示例#3
0
        public void PresentPayslipConsole(PayslipInformation payslipInformation)
        {
            Console.WriteLine("\r\nYour payslip has been generated\r\n");

            Console.WriteLine("Name: " + payslipInformation.Fullname);


            string startMonth = _monthDictionary.FirstOrDefault(x => x.Value == payslipInformation.PaymentStartDate.Month).Key;
            string endMonth   = _monthDictionary.FirstOrDefault(x => x.Value == payslipInformation.PaymentEndDate.Month).Key;

            Console.WriteLine("Pay Period: {0} {1} - {2} {3}", payslipInformation.PaymentStartDate.Day, startMonth, payslipInformation.PaymentEndDate.Day, endMonth);

            Console.WriteLine("Gross Income: " + payslipInformation.GrossIncome);

            Console.WriteLine("Income Tax: " + payslipInformation.IncomeTax);

            Console.WriteLine("Net Income: " + payslipInformation.NetIncome);

            Console.WriteLine("Super: " + payslipInformation.Super + "\r\n");
        }