Exemple #1
0
        private void displayThePayslip(Payslip payslip)
        {
            //set the labels in the payslip
            this.labelNameValue.Text = payslip.stringFirstName + " " + payslip.stringLastName;
            this.labelGrossIncomeValue.Text = payslip.decimalGrossIncome.ToString();
            this.labelIncomeTaxValue.Text = payslip.decimalIncomeTax.ToString();
            this.labelNetIncomeValue.Text = payslip.decimalNetIncome.ToString();
            this.labelPayPeriodValue.Text = payslip.stringPayslipPeriod;
            this.labelSuperValue.Text = payslip.decimalSuper.ToString();
            this.labelAnnualSalaryValue.Text = uintAnnualSalary.ToString();
            this.labelSuperRatePayslip.Text = uintSuperRate.ToString() + "%";

        }
Exemple #2
0
        public void createPayslipFromLineStringTest()
        {
            string payslipLine1FromFile = "David, Rudd,Mar 2015,5004,922,4082,450";
            Payslip payslip1 = new Payslip(payslipLine1FromFile);
            Assert.AreEqual(payslip1.stringFirstName , "David" );
            Assert.AreEqual(payslip1.stringLastName, "Rudd");
            Assert.AreEqual(payslip1.stringPayslipPeriod, "Mar 2015");
            Assert.AreEqual(payslip1.decimalGrossIncome, 5004);
            Assert.AreEqual(payslip1.decimalIncomeTax, 922);
            Assert.AreEqual(payslip1.decimalNetIncome, 4082);
            Assert.AreEqual(payslip1.decimalSuper, 450);

            string payslipLine2FromFile = "Ryan, Chen , Mar 2015 , 10000 , 2696, 7304, 1000";
            Payslip payslip2 = new Payslip(payslipLine2FromFile);

            Assert.AreEqual(payslip2.stringFirstName, "Ryan");
            Assert.AreEqual(payslip2.stringLastName, "Chen");
            Assert.AreEqual(payslip2.stringPayslipPeriod, "Mar 2015");
            Assert.AreEqual(payslip2.decimalGrossIncome, 10000);
            Assert.AreEqual(payslip2.decimalIncomeTax, 2696);
            Assert.AreEqual(payslip2.decimalNetIncome, 7304);
            Assert.AreEqual(payslip2.decimalSuper, 1000);

            string payslipLine3FromFile = "Teodor, Cotruta, Apr 2012 , 1235.5, 912.2, 25.5, 17.99";
            try {
                Payslip payslip3 = new Payslip(payslipLine3FromFile);

                Assert.AreEqual(payslip3.stringFirstName, "Teodor");
                Assert.AreEqual(payslip3.stringLastName, "Cotruta");
                Assert.AreEqual(payslip3.stringPayslipPeriod, "Apr 2012");

                // the right hand side is converted to decimal, implicitely 
                Assert.AreEqual(payslip3.decimalGrossIncome, 1235.5);
                Assert.AreEqual(payslip3.decimalIncomeTax, 912.2);
                Assert.AreEqual(payslip3.decimalNetIncome, 25.5);
                Assert.AreEqual(payslip3.decimalSuper, 17.99);
            }
            catch (FormatException fe)
            {
                Console.WriteLine("{0}: Bad Format", fe.Message);
            }
            catch (OverflowException oe)
            {
                Console.WriteLine("{0}: Overflow", oe.Message);
            }
            catch(PayslipException pe)
            {
                Console.WriteLine("{0}: Overflow", pe.Message);
            }
        }
Exemple #3
0
 // this can be called from reading a file with payslips,
 // or after calculating a payslip
 // we may require same methods for the payslips
 // so next run will find them, but for that we require an installer
 // for the program
 public void add(Payslip payslip)
 {
     iSetPayslips.Add(payslip);
 }
Exemple #4
0
 // this can be called from reading a file with payslips, 
 // or after calculating a payslip
 // we may require same methods for the payslips
 // so next run will find them, but for that we require an installer
 // for the program
 public void add(Payslip payslip)
 {
     iSetPayslips.Add(payslip);
 }
Exemple #5
0
        private Payslip calculateThePaySlip()
        {
            Payslip payslip = new Payslip();

            //set the user details, say header of the payslip
            payslip.stringFirstName = this.stringFirstName;
            payslip.stringLastName = this.stringLastName;
            payslip.stringPayslipPeriod = this.dateTimePickerPaysleepPeriod.Value.ToString("MMM yyyy");

            // set the calculated values
            // this is mm yyyy
            // we should get the number of days after the start date of employment
            // here we assume the employee has been working the full month
            // and we don't check the employment start date
            Calculator calculator = new Calculator(stringPayslipPeriod, uintAnnualSalary, uintSuperRate);
            payslip.decimalGrossIncome = calculator.getGrossIncome();
            payslip.decimalIncomeTax = calculator.getIncomeTax();
            payslip.decimalNetIncome = calculator.getNetIncome();
            payslip.decimalSuper = calculator.getSuper();

            // ready for display
            return payslip;
        }