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 classA 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 TypeMethodDescriptiondoubleA description of the entire Java function.doubleCalculate the net pay by subtracting the total deduction from the gross pay.doubleCalculates the PagIbig contribution based on the salary.doubleCalculate the partial deduction by adding the calculated SSS, PhilHealth, and PagIbig contributions.doubleCalculate the PhilHealth contribution based on the salary.doubleCalculate the Social Security contribution based on the salary using a predefined table.doubleCalculate the total allowances by summing up the rice subsidy, phone allowance, and clothing allowance.doubleCalculate the total deduction by summing up the results of partial deduction and withholding tax calculation.doubleCalculates the withholding tax based on the gross pay and partial deduction.doubleA method to calculate overtime pay.doublesalary()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:
overtimePayin 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:
salaryin interfaceSalaryAdjustment- Returns:
- the calculated salary
-
calculateSSS
public double calculateSSS()Calculate the Social Security contribution based on the salary using a predefined table.- Specified by:
calculateSSSin interfaceTaxAndDeductions- Returns:
- the Social Security contribution amount
-
calculatePhilHealth
public double calculatePhilHealth()Calculate the PhilHealth contribution based on the salary.- Specified by:
calculatePhilHealthin interfaceTaxAndDeductions- Returns:
- the calculated PhilHealth contribution
-
calculatePagIbig
public double calculatePagIbig()Calculates the PagIbig contribution based on the salary.- Specified by:
calculatePagIbigin 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:
calculatePartialDeductionin 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:
calculateTotalDeductionin interfaceTaxAndDeductions- Returns:
- the total deduction amount
-
calculateWithholdingTax
public double calculateWithholdingTax()Calculates the withholding tax based on the gross pay and partial deduction.- Specified by:
calculateWithholdingTaxin interfacePayroll- Returns:
- the withholding tax amount
-
calculateGrossPay
public double calculateGrossPay()A description of the entire Java function.- Specified by:
calculateGrossPayin 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:
calculateNetPayin 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:
calculateTotalAllowancesin interfaceAllowance- Returns:
- the total allowances calculated
-