public override bool Equals(object obj)
        {
            var item = obj as PayslipEntity;

            if (item == null)
            {
                return(false);
            }
            return(FirstName.Equals(item.FirstName) &&
                   LastName.Equals(item.LastName) &&
                   PayPeriod.Equals(item.PayPeriod) &&
                   GrossIncome.Equals(item.GrossIncome) &&
                   IncomeTax.Equals(item.IncomeTax) &&
                   NetIncome.Equals(item.NetIncome) &&
                   SuperAnnuation.Equals(item.SuperAnnuation));
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var firstNameInput = StandardMessage.CaptureData("first name");
            var surnameInput   = StandardMessage.CaptureData("surname");

            var annualSalaryInput = StandardMessage.CaptureData("annual salary");

            var superRateInput = StandardMessage.CaptureData("super rate");

            var startDate = StandardMessage.CaptureData("payment start date");
            var endDate   = StandardMessage.CaptureData("payment end date");

            var bracket1 = TaxBracket.Generate(0M, 18200M, 0M, 0M);
            var bracket2 = TaxBracket.Generate(18201M, 37000M, 0M, 0.325M);
            var bracket3 = TaxBracket.Generate(37001M, 87000M, 3572M, 0.325M);
            var bracket4 = TaxBracket.Generate(87001M, 180000M, 19822M, 0.37M);
            var bracket5 = TaxBracket.Generate(180000M, Int32.MaxValue, 54232M, 0.45M);

            var taxTable = TaxTable.Build(bracket1, bracket2, bracket3, bracket4, bracket5);

            EmployeeDetails employeeDetails = EmployeeDetails.ConstructFullName(firstNameInput, surnameInput);

            PayPeriod payPeriod = PayPeriod.Generate(startDate, endDate);

            GrossIncome grossIncome = GrossIncome.Generate(annualSalaryInput, payPeriod);
            IncomeTax   incomeTax   = IncomeTax.Generate(taxTable, grossIncome, payPeriod);
            NetIncome   netIncome   = NetIncome.Generate(grossIncome, incomeTax);

            Super super = Super.Generate(superRateInput, grossIncome);

            var paySlip = PaySlip.Create(
                employeeDetails,
                payPeriod,
                grossIncome,
                incomeTax,
                netIncome,
                super
                );

            var payslipOutput = PayslipBuilder.Print(paySlip);

            Console.WriteLine(payslipOutput);
//
        }
Beispiel #3
0
        private void performDetailDataRefineBS()
        {
            string tmpkey    = "";
            double tmpAmount = 0;

            vRevenue = vExpense = NetIncome = TotalLE = lSubTotal = aSubTotal = 0;

            foreach (DataRow eRow in ds.Tables[ParentTable].Rows)
            {
                tmpkey    = eRow["Type"].ToString().Trim();
                tmpAmount = double.Parse(eRow["Amount"].ToString()) + double.Parse(eRow["Begin_Balance"].ToString());
                switch (tmpkey)
                {
                case CONST__MASTER_ASSET_NAME:
                    eRow["Amount"] = tmpAmount.ToString();
                    aSubTotal      = aSubTotal + tmpAmount;
                    break;

                case CONST__MASTER_LIABILITY_NAME:
                    tmpAmount      = tmpAmount * -1;
                    eRow["Amount"] = tmpAmount.ToString();
                    lSubTotal      = lSubTotal + tmpAmount;
                    break;

                case CONST__MASTER_EQUITY_NAME:
                    tmpAmount      = tmpAmount * -1;
                    eRow["Amount"] = tmpAmount.ToString();
                    vRevenue       = vRevenue + double.Parse(tmpAmount.ToString());
                    break;

                default:
                    break;
                }
            }

            foreach (DataRow eRow in ds.Tables[ChildTable].Rows)
            {
                tmpkey    = eRow["Type"].ToString().Trim();
                tmpAmount = double.Parse(eRow["Amount"].ToString()) + double.Parse(eRow["Begin_Balance"].ToString());
                switch (tmpkey)
                {
                case CONST__MASTER_ASSET_NAME:
                    eRow["Amount"] = tmpAmount.ToString();
                    break;

                case CONST__MASTER_LIABILITY_NAME:
                    tmpAmount      = tmpAmount * -1;
                    eRow["Amount"] = tmpAmount.ToString();
                    break;

                case CONST__MASTER_REVENUE_NAME:
                    tmpAmount      = tmpAmount * -1;
                    eRow["Amount"] = tmpAmount.ToString();
                    break;

                case CONST__MASTER_EXPENSE_NAME:
                    tmpAmount      = tmpAmount * -1;
                    eRow["Amount"] = tmpAmount.ToString();
                    break;

                default:
                    break;
                }
            }


            NetIncome = vRevenue + vExpense;
            TotalLE   = lSubTotal + NetIncome;

            A_TOTAL.Text  = string.Format("Asset : {0:n2}      ", aSubTotal);
            LE_TOTAL.Text = string.Format("Liabilty & Equity : {0:n2}      ", TotalLE);

            DataTable dt = new DataTable("HEAD");
            DataRow   dr;

            dt.Columns.Add(new DataColumn("Type", typeof(string)));
            dt.Columns.Add(new DataColumn("Amount", typeof(System.Decimal)));

            dr    = dt.NewRow();
            dr[0] = CONST__MASTER_ASSET_NAME;
            dr[1] = double.Parse(aSubTotal.ToString());
            dt.Rows.Add(dr);

            dr    = dt.NewRow();
            dr[0] = CONST__MASTER_LIABILITY_NAME;
            dr[1] = lSubTotal.ToString();
            dt.Rows.Add(dr);

            dr    = dt.NewRow();
            dr[0] = CONST__MASTER_EQUITY_NAME;
            dr[1] = NetIncome.ToString();
            dt.Rows.Add(dr);

            ds.Tables.Add(dt);

            ds_AS = ds.Copy();
            ds_LE = ds.Copy();

            for (int i = ds_AS.Tables["HEAD"].Rows.Count - 1; i >= 0; i--)
            {
                DataRow eRow = ds_AS.Tables["HEAD"].Rows[i];
                if (eRow["Type"].ToString() != CONST__MASTER_ASSET_NAME)
                {
                    ds_AS.Tables["HEAD"].Rows.Remove(eRow);
                }
            }

            for (int i = ds_AS.Tables[ParentTable].Rows.Count - 1; i >= 0; i--)
            {
                DataRow eRow = ds_AS.Tables[ParentTable].Rows[i];
                if (eRow["Type"].ToString() != CONST__MASTER_ASSET_NAME)
                {
                    ds_AS.Tables[ParentTable].Rows.Remove(eRow);
                }
            }

            for (int i = ds_AS.Tables[ChildTable].Rows.Count - 1; i >= 0; i--)
            {
                DataRow eRow = ds_AS.Tables[ChildTable].Rows[i];
                if (eRow["Type"].ToString() != CONST__MASTER_ASSET_NAME)
                {
                    ds_AS.Tables[ChildTable].Rows.Remove(eRow);
                }
            }

//

            for (int i = ds_LE.Tables["HEAD"].Rows.Count - 1; i >= 0; i--)
            {
                DataRow eRow = ds_LE.Tables["HEAD"].Rows[i];
                if (eRow["Type"].ToString() == CONST__MASTER_ASSET_NAME)
                {
                    ds_LE.Tables["HEAD"].Rows.Remove(eRow);
                }
            }

            for (int i = ds_LE.Tables[ParentTable].Rows.Count - 1; i >= 0; i--)
            {
                DataRow eRow = ds_LE.Tables[ParentTable].Rows[i];
                if (eRow["Type"].ToString() == CONST__MASTER_ASSET_NAME)
                {
                    ds_LE.Tables[ParentTable].Rows.Remove(eRow);
                }
            }

            for (int i = ds_LE.Tables[ChildTable].Rows.Count - 1; i >= 0; i--)
            {
                DataRow eRow = ds_LE.Tables[ChildTable].Rows[i];
                if (eRow["Type"].ToString() == CONST__MASTER_ASSET_NAME)
                {
                    ds_LE.Tables[ChildTable].Rows.Remove(eRow);
                }
            }
        }
Beispiel #4
0
        public static PayrollReportRecord[] GeneratePayRollRecord(
            EmployeeMonthlyRecord[] employeeMonthlyRecords,
            SalaryConfig salaryConfig)
        {
            return(employeeMonthlyRecords.Select(employeeMonthlyRecord =>
            {
                var insuranceSalary = InsuranceCalculator.CalculateInsuranceSalary(
                    salaryConfig: salaryConfig,
                    employeeMonthlyRecord: employeeMonthlyRecord);

                var actualGrossSalary = new ActualGrossSalary(
                    grossContractedSalary: employeeMonthlyRecord.GrossContractedSalary,
                    standardWorkingDays: employeeMonthlyRecord.StandardWorkingDays,
                    probationWorkingDays: employeeMonthlyRecord.ProbationWorkingDays,
                    workingDays: employeeMonthlyRecord.WorkingDays);

                var employeeSocialInsurance = InsuranceCalculator.CalculateEmployeeSocialInsurance(
                    salaryConfig: salaryConfig,
                    employeeMonthlyRecord: employeeMonthlyRecord,
                    insuranceSalary: insuranceSalary);
                var employeeUnemploymentInsurance = InsuranceCalculator.CalculateEmployeeUnemploymentInsurance(
                    salaryConfig: salaryConfig,
                    employeeMonthlyRecord: employeeMonthlyRecord,
                    insuranceSalary: insuranceSalary);
                var employeeHealthcareInsurance = InsuranceCalculator.CalculateEmployeeHealthCareInsurance(
                    salaryConfig: salaryConfig,
                    employeeMonthlyRecord: employeeMonthlyRecord,
                    insuranceSalary: insuranceSalary);
                var employeeUnionFee = InsuranceCalculator.CalculateEmployeeUnionFee(salaryConfig: salaryConfig,
                                                                                     employeeMonthlyRecord: employeeMonthlyRecord,
                                                                                     insuranceSalary: insuranceSalary);

                var employerSocialInsurance = InsuranceCalculator.CalculateEmployerSocialInsurance(
                    salaryConfig: salaryConfig,
                    employeeMonthlyRecord: employeeMonthlyRecord,
                    insuranceSalary: insuranceSalary);
                var employerUnemploymentInsurance = InsuranceCalculator.CalculateEmployerUnemploymentInsurance(
                    salaryConfig: salaryConfig,
                    employeeMonthlyRecord: employeeMonthlyRecord,
                    insuranceSalary: insuranceSalary);
                var employerHealthcareInsurance = InsuranceCalculator.CalculateEmployerHealthCareInsurance(
                    salaryConfig: salaryConfig,
                    employeeMonthlyRecord: employeeMonthlyRecord,
                    insuranceSalary: insuranceSalary);
                var employerUnionFee = InsuranceCalculator.CalculateEmployerUnionFee(salaryConfig: salaryConfig,
                                                                                     employeeMonthlyRecord: employeeMonthlyRecord,
                                                                                     insuranceSalary: insuranceSalary);

                var taxableIncome = new TaxableIncome(actualGrossSalary, employeeMonthlyRecord.TaxableAllowances);

                var assessableIncome = new AssessableIncome(
                    taxableIncome,
                    employeeSocialInsurance: employeeSocialInsurance,
                    employeeHealthCareInsurance: employeeHealthcareInsurance,
                    employeeUnemploymentInsurance: employeeUnemploymentInsurance,
                    employeeUnionFee: employeeUnionFee,
                    totalDeduction: new TotalDeduction(employeeMonthlyRecord: employeeMonthlyRecord,
                                                       salaryConfig: salaryConfig));

                var pit = employeeMonthlyRecord.IsOnProbation()
                                        ? new PersonalIncomeTax((assessableIncome.Amount * salaryConfig.DefaultProbationTaxRate).Round())
                                        : salaryConfig.ProgressiveTaxRateLookUpTable[assessableIncome];

                var totalMonthlyIncome = new TotalMonthlyIncome(
                    actualGrossSalary: actualGrossSalary,
                    taxableAllowances: employeeMonthlyRecord.TaxableAllowances,
                    nonTaxableAllowances: employeeMonthlyRecord.NonTaxableAllowances);

                var netIncome = new NetIncome(
                    totalMonthlyIncome: totalMonthlyIncome,
                    employeeHealthcareInsurance: employeeHealthcareInsurance,
                    employeeSocialInsurance: employeeSocialInsurance,
                    employeeUnemploymentInsurance: employeeUnemploymentInsurance,
                    employeeUnionFee: employeeUnionFee,
                    pit: pit);

                return new PayrollReportRecord(
                    employeeMonthlyRecord: employeeMonthlyRecord,
                    insuranceSalary: insuranceSalary.Amount,
                    actualGrossSalary: actualGrossSalary.Amount,
                    totalMonthlyIncome: totalMonthlyIncome.Amount,
                    taxableIncome: taxableIncome.Amount,
                    employeeSocialInsurance: employeeSocialInsurance.Amount,
                    employeeHealthcareInsurance: employeeHealthcareInsurance.Amount,
                    employeeUnemploymentInsurance: employeeUnemploymentInsurance.Amount,
                    employeeUnionFee: employeeUnionFee.Amount,
                    employerSocialInsurance: employerSocialInsurance.Amount,
                    employerHealthcareInsurance: employerHealthcareInsurance.Amount,
                    employerUnemploymentInsurance: employerUnemploymentInsurance.Amount,
                    employerUnionFee: employerUnionFee.Amount,
                    personalDeduction: salaryConfig.PersonalDeduction,
                    dependantDeduction: salaryConfig.DependantDeduction * employeeMonthlyRecord.NumberOfDependants,
                    assessableIncome: assessableIncome.Amount,
                    netIncome: netIncome.Amount,
                    pit: pit.Amount,
                    totalSalaryCost: new TotalSalaryCost(
                        totalMonthlyIncome: totalMonthlyIncome,
                        employerSocialInsurance: employerSocialInsurance,
                        employerHealthcareInsurance: employerHealthcareInsurance,
                        employerUnemploymentInsurance: employerUnemploymentInsurance,
                        employerUnionFee: employerUnionFee).Amount,
                    netPayment: new NetPayment(
                        netIncome: netIncome,
                        paymentAdvance: employeeMonthlyRecord.PaymentAdvance,
                        adjustmentAdditions: employeeMonthlyRecord.AdjustmentAdditions,
                        adjustmentDeductions: employeeMonthlyRecord.AdjustmentDeduction
                        ).Amount);
            }).ToArray());
        }