java.lang.Object
calculator.PayrollCalculator
- All Implemented Interfaces:
Allowance
,Payroll
,SalaryAdjustment
,TaxAndDeductions
public class PayrollCalculator
extends Object
implements SalaryAdjustment, Allowance, TaxAndDeductions, Payroll
A class representing a payroll calculator that implements salary adjustments, allowances, tax, and deductions.
It calculates various components of payroll including overtime pay, salary, contributions, deductions, and net pay.
Implements the following interfaces:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A class to calculate the tax based on the taxable income. -
Constructor Summary
ConstructorsConstructorDescriptionPayrollCalculator
(double hoursWorked, double overTimeHours, double hourlyRate) PayrollCalculator
(double hoursWorked, double overTimeHours, double hourlyRate, double riceSubsidy, double phoneAllowance, double clothingAllowance) Creates a new instance of the PayrollCalculator class. -
Method Summary
Modifier and TypeMethodDescriptiondouble
A description of the entire Java function.double
Calculate the net pay by subtracting the total deduction from the gross pay.double
Calculates the PagIbig contribution based on the salary.double
Calculate the partial deduction by adding the calculated SSS, PhilHealth, and PagIbig contributions.double
Calculate the PhilHealth contribution based on the salary.double
Calculate the Social Security contribution based on the salary using a predefined table.double
Calculate the total allowances by summing up the rice subsidy, phone allowance, and clothing allowance.double
Calculate the total deduction by summing up the results of partial deduction and withholding tax calculation.double
Calculates the withholding tax based on the gross pay and partial deduction.double
A method to calculate overtime pay.double
salary()
Calculate the salary based on the hours worked, hourly rate, and overtime pay.
-
Constructor Details
-
PayrollCalculator
public PayrollCalculator(double hoursWorked, double overTimeHours, double hourlyRate, double riceSubsidy, double phoneAllowance, double clothingAllowance) Creates a new instance of the PayrollCalculator class.- Parameters:
hoursWorked
- the number of hours worked by the employeeoverTimeHours
- the number of overtime hours of the employeehourlyRate
- the hourly rate of the employeericeSubsidy
- the rice subsidy of the employeephoneAllowance
- the phone allowance of the employeeclothingAllowance
- the clothing allowance of the employee
-
PayrollCalculator
public PayrollCalculator(double hoursWorked, double overTimeHours, double hourlyRate)
-
-
Method Details
-
overtimePay
public double overtimePay()A method to calculate overtime pay.- Specified by:
overtimePay
in interfaceSalaryAdjustment
- Returns:
- the calculated overtime pay
-
salary
public double salary()Calculate the salary based on the hours worked, hourly rate, and overtime pay.- Specified by:
salary
in interfaceSalaryAdjustment
- Returns:
- the calculated salary
-
calculateSSS
public double calculateSSS()Calculate the Social Security contribution based on the salary using a predefined table.- Specified by:
calculateSSS
in interfaceTaxAndDeductions
- Returns:
- the Social Security contribution amount
-
calculatePhilHealth
public double calculatePhilHealth()Calculate the PhilHealth contribution based on the salary.- Specified by:
calculatePhilHealth
in interfaceTaxAndDeductions
- Returns:
- the calculated PhilHealth contribution
-
calculatePagIbig
public double calculatePagIbig()Calculates the PagIbig contribution based on the salary.- Specified by:
calculatePagIbig
in interfaceTaxAndDeductions
- Returns:
- the calculated PagIbig contribution
-
calculatePartialDeduction
public double calculatePartialDeduction()Calculate the partial deduction by adding the calculated SSS, PhilHealth, and PagIbig contributions.- Specified by:
calculatePartialDeduction
in interfaceTaxAndDeductions
- Returns:
- the total partial deduction
-
calculateTotalDeduction
public double calculateTotalDeduction()Calculate the total deduction by summing up the results of partial deduction and withholding tax calculation.- Specified by:
calculateTotalDeduction
in interfaceTaxAndDeductions
- Returns:
- the total deduction amount
-
calculateWithholdingTax
public double calculateWithholdingTax()Calculates the withholding tax based on the gross pay and partial deduction.- Specified by:
calculateWithholdingTax
in interfacePayroll
- Returns:
- the withholding tax amount
-
calculateGrossPay
public double calculateGrossPay()A description of the entire Java function.- Specified by:
calculateGrossPay
in interfacePayroll
- Returns:
- description of return value
-
calculateNetPay
public double calculateNetPay()Calculate the net pay by subtracting the total deduction from the gross pay.- Specified by:
calculateNetPay
in interfacePayroll
- Returns:
- the net pay calculated
-
calculateTotalAllowances
public double calculateTotalAllowances()Calculate the total allowances by summing up the rice subsidy, phone allowance, and clothing allowance.- Specified by:
calculateTotalAllowances
in interfaceAllowance
- Returns:
- the total allowances calculated
-