40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
/**
|
|
* StaffManager: Handles staff records, attendance, and payroll.
|
|
*/
|
|
|
|
class StaffManager {
|
|
constructor() {
|
|
this.staff = [
|
|
{ id: 'S001', name: 'Dr. Sharma', role: 'Doctor', salary: 120000, incentives: 4500, status: 'PRESENT' },
|
|
{ id: 'S002', name: 'Anjali Singh', role: 'Pharmacist', salary: 35000, incentives: 1200, status: 'PRESENT' },
|
|
{ id: 'S003', name: 'Vikram Goel', role: 'Lab Tech', salary: 28000, incentives: 800, status: 'ABSENT' },
|
|
{ id: 'S004', name: 'Priya Raj', role: 'Nurse', salary: 25000, incentives: 0, status: 'PRESENT' }
|
|
];
|
|
}
|
|
|
|
getStaffList() {
|
|
return this.staff;
|
|
}
|
|
|
|
calculatePayroll(staffId) {
|
|
const member = this.staff.find(s => s.id === staffId);
|
|
if (member) {
|
|
return {
|
|
base: member.salary,
|
|
incentives: member.incentives,
|
|
total: member.salary + member.incentives
|
|
};
|
|
}
|
|
return null;
|
|
}
|
|
|
|
updateStatus(staffId, status) {
|
|
const member = this.staff.find(s => s.id === staffId);
|
|
if (member) {
|
|
member.status = status;
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = new StaffManager();
|