Skip to content

feat: employee_attendance#41

Open
lekshmi-mb wants to merge 2 commits intoKBA-Learning:devfrom
lekshmi-mb:feature/employee_attendance
Open

feat: employee_attendance#41
lekshmi-mb wants to merge 2 commits intoKBA-Learning:devfrom
lekshmi-mb:feature/employee_attendance

Conversation

@lekshmi-mb
Copy link

Description

This PR implements an employee attendance tracking system in Go. It introduces an Employee struct with methods to calculate attendance rates and determine if an employee is regular based on their attendance percentage.

Related Issue

Fixes Employee Attendance #10

Type of Change

  • New feature (non-breaking change which adds functionality)

Changes Made

  • Created /go/employeeattendance/ folder structure
  • Implemented Employee struct with PresentDays and WorkingDays fields
  • Added AttendanceRate() method to calculate attendance percentage
  • Added IsRegular() method to check if attendance meets 80% threshold
  • Implemented comprehensive test cases for both methods

Testing

The following tests were implemented and are passing:

  1. TestAttendanceRate: Verifies that attendance percentage is calculated correctly

    • Test case: 24 present days out of 30 working days = 80% attendance
  2. TestIsRegular: Tests the regular attendance status with multiple scenarios

    • Regular Employee: 28/30 days (passes 80% threshold)
    • Irregular Employee: 10/30 days (below 80% threshold)
    • Edge Case: 0/0 days (returns false for zero working days)

To run the tests:

cd go/employeeattendance
go test -v

Screenshots

Not applicable (CLI-based implementation)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code with clear documentation
  • My changes generate no new warnings
  • I have added tests that prove my feature works
  • New and existing unit tests pass locally with my changes

Additional Notes

The implementation follows Go best practices with:

  • Clear separation of concerns
  • Proper error handling for edge cases (e.g., zero working days)
  • Comprehensive test coverage including edge cases
  • Clean code with proper documentation
  • Type-safe implementation using appropriate data types (int for days, float64 for percentage)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant