Attached are a scaffold file code payroll.py and a CSV file HR.csv. The csv file contains 4 columns:
- employee ID
- compensation rate-which can be hourly or monthly
- whether an employee is salaried
- reported worked hours for the past month
The program should generate the paystubs of all employees in a company. However, the earnings calculation depends on the employee status. For instance, only a few managers are salaried while the remaining staff are paid on an hourly basis. Additionally, interns are not allowed to get extra pay for overtime hours like regular employees.
In the payroll.py module, you are given the implementation of the class employee including the method paystub () which returns the net earnings as well as a string with the paystub text. You are required to complete the implementation of the Manager and Intern derived classes, as well as the main() function, following the guidelines below:
- The class Manager redefines the inherited paystub () method such that:
• If the manager is salaried, the gross earning is equal to the (monthly) rate. Calculation of the tax withholding and the net earning is the same as for regular employees. The pay stub text contains the gross, withholding and net amounts (no base or overtime)
• If the manager is not salaried, his/her paystub is processed like regular employees.
- The information about the compensation type (salaried or not) should be recorded in Manager objects at instantiation time. (Re)define the proper method for this purpose.
- The class Intern redefines the inherited paystub () method such that overtime hours are accounted for just like regular hours i.e. the gross earning is equal to the number of worked hours multiplied by the (hourly) rate. Calculation of the tax withholding and the net earning is the same as for regular employees. The pay stub text contains the gross, withholding and net amounts (no base or overtime)
- The paystub () method should have the same argument and return values across classes such that it can be called in the same way on objects from either class.
- In the main() function, generate the stub of each employee listed in the csv file by creating the proper corresponding object and calling its paystub () method. All employee stubs (strings) must be stored in the dictionary payroll, where they are associated with the employee ID as a key. Note that to distinguish the type of staff member, the last character in the ID must be either "M" for a manager, "R" for a (regular) employee and "1" for an intern
- The output of the payroll.py module, when using the provided HR.csv input file, must be as follows.
Fig: 1