عدم إغلاق اليوم تلقائياً للموظف
مكان المشكلة:

الحضور اليومي

GET /api/v1/attendances/list

الوصف:
إذا لم يسجل الموظف خروج، لا يتم التعامل مع الحالة.

المطلوب:
تسجيل خروج تلقائي
تحديد الحالة: تسجيل غير مكتمل
إتاحة فلترة لتعديلها من قبل المسؤول

--------------

عدم وجود Endpoint لإدارة مخالفات الموظفين

مكان المشكلة:
المخالفات

الوصف:
لا يوجد API لإدارة المخالفات التي نتجت عن تاخير .. حسب قواعد المخالفات.

المطلوب:
إنشاء Endpoint لإرجاع جميع المخالفات مع خيارات:
تخطي المخالفة
إضافة غرامة على الراتب

بناءً على attendanceViolationTypes
-------------
عدم التحقق من موقع الحضور والانصراف هل مرتبط بمكان العمل بشكل صحيح أم لا
مكان المشكلة:

API
POST /attendances

الوصف:
الحضور والانصراف

الوصف:
لا يتم عرض الموقع الفعلي الذي سجل منه الموظف الحضور أو الانصراف ولا يتم التحقق منه أثناء الإضافة

منع تسجيل:
الدخول
الخروج
بداية/نهاية الاستراحة

إلا في حال تفعيل ذلك من إعدادات الحضور

المطلوب:
تخزين وإرجاع موقع (GPS أو IP) لكل عملية Check-in / Check-out


------------

عدم إرجاع جميع الموظفين في Endpoint الحضور مع حالتهم


مكان المشكلة:
API
GET /api/v1/attendances/list

الوصف:
الـ endpoint لا يعرض حالة جميع الموظفين بشكل شامل.

المطلوب:
إرجاع جميع الموظفين النشطين في النظام مع الحالة:
متأخر
غائب
في إجازة
انصراف مبكر

مع إمكانية الفلترة حسب الحالة

----------
تسجيل الغياب في أيام العطل الرسمية

مكان المشكلة:
العطلات الرسمية
API /official-holidays

الوصف:
يتم احتساب الموظف غائب رغم وجود عطلة رسمية.

المطلوب:
استثناء أيام العطل الرسمية من الغياب تلقائياً

-----------
تقرير الموظفين في إجازة  لا يتم إرجاع أي بيانات به
demoback.rzain.com.tr/api/v1/attendances/dashboard/employees-on-leave

-------------
العمل الإضافي
Request URL
https://demoback.rzain.com.tr/api/v1/overtime?page=1
Request Method
GET

لاتقوم بإرجاع أي بيانات للموظفين للعمل الاضافي
----------------------
فلترة الإجازات لا تعمل بشكل صحيح

مكان المشكلة:
API
GET /api/v1/leaves

الوصف:
الفلترة حسب:
نوع الإجازة
الفئة
التاريخ

لا تعمل

المطلوب:
دعم فلترة التاريخ بنظام Range (من - إلى)
تصحيح باقي الفلاتر


------------------
عدم توليد الرقم الوظيفي تلقائياً

مكان المشكلة:

https://demoback.rzain.com.tr/api/v1/users?page=1&search=&labor_category_id=&join_date_from=&join_date_to=&status=&perPage=10
قسم الموارد البشرية
→ الموظفين

الوصف:
الرقم الوظيفي لا يتم إنشاؤه من الباك اند.

المطلوب:
إنشاء Employee ID تلقائياً لكل موظف

-----------------
نقص حقول أساسية في بيانات الموظف
مكان المشكلة:

https://demoback.rzain.com.tr/api/v1/users?page=1&search=&labor_category_id=&join_date_from=&join_date_to=&status=&perPage=10
قسم الموارد البشرية
→ الموظفين
→ إضافة / تعديل

الوصف:
بيانات الموظف غير مكتملة ولا تحتوي على حقول أساسية لإدارة الموارد البشرية.

المطلوب إضافة الحقول التالية:
الحالة الوظيفية (Active / On Leave / Terminated)
المدير المباشر (Manager ID)
الفرع
رقم الهوية / الإقامة
سجل التغييرات (Audit Trail) (يظهر ضمن صفحة تفاصيل الموظف)



---------------
تعديلات في قسم المكافآات والخصومات

عند اضافة خصم تابع لاجازة غير مدفوعة ضمن قسم الخصومات يجب توضيح أن هذا الخصم تابع لإجازة غير مدفوعة رقمها كذا ..

يجب اضافة رمز تسلسلي بنفس فاتورة الشراء مثلا (po -001) لقسم الاجازات والاذونات وقسم المكافآات والخصومات

Request URL

https://demoback.rzain.com.tr/api/v1/rewards?page=0

Request Method

GET

Status Code

# Backend Fix Prompts

## Issue 1: Attendance Not Auto-Closing

### Prompt

Investigate the attendance module handling in `GET /api/v1/attendances/list` and related services responsible for daily attendance processing.

#### Problem

Currently, if an employee performs a check-in but does not perform a check-out, the system leaves the attendance record open without any resolution or status handling.

#### Expected Behavior

* The system should automatically close open attendance records at the end of the working day.
* The record should be marked with a status such as:

  * `INCOMPLETE`
  * or equivalent based on system conventions.
* The auto check-out time should follow a defined rule (e.g., end of shift, system default time, or configurable value).

#### Requirements

* Add logic to detect open attendance records.
* Implement auto check-out mechanism (scheduled job or query-time handling).
* Introduce a new status field or reuse existing one to indicate incomplete attendance.
* Ensure this status is:

  * Returned in `GET /attendances/list`
  * Filterable by admins

#### Notes

If no scheduling mechanism exists, investigate whether to implement via cron job, queue worker, or runtime fallback logic.

---

## Issue 2: Missing Violations Management Endpoint

### Prompt

Analyze how attendance violations are currently calculated or referenced via `attendanceViolationTypes`.

#### Problem

There is no API to retrieve or manage violations الناتجة عن التأخير أو المخالفات المرتبطة بالحضور.

#### Expected Behavior

* Provide an endpoint to list all employee violations.
* Each violation should include:

  * Employee reference
  * Violation type
  * Date
  * Status (pending / processed)

#### Requirements

* Create a new endpoint (e.g., `/api/v1/violations`)
* Support actions:

  * Skip violation
  * Apply financial penalty (deduction)
* Link violations to payroll or deductions module if applicable.
* Ensure violations are derived based on `attendanceViolationTypes`.

#### Notes

If violation calculation logic does not exist, investigate how it should be derived from attendance delays.

---

## Issue 3: Missing Location Validation in Attendance

### Prompt

Review `POST /attendances` and related attendance creation logic.

#### Problem

* The system does not store the actual location (GPS or IP).
* No validation is performed to ensure the employee is within an allowed work location.

#### Expected Behavior

* Capture and store:

  * GPS coordinates and/or IP address for each action:

    * Check-in
    * Check-out
    * Break start/end
* Validate location only if enabled in attendance settings.

#### Requirements

* Extend attendance model to store location metadata.
* Add validation layer:

  * Compare employee location with allowed workplace location.
* Make validation configurable via settings.
* Return location data in API responses.

#### Notes

If no location settings exist, define structure consistent with existing config patterns.

---

## Issue 4: Attendance Endpoint Missing Employee Status Coverage

### Prompt

Analyze `GET /api/v1/attendances/list`.

#### Problem

The endpoint does not return all employees or provide a complete attendance status overview.

#### Expected Behavior

Return all active employees with computed attendance status:

* Late
* Absent
* On Leave
* Early Leave
* Present

#### Requirements

* Join attendance with:

  * employees
  * leaves
  * schedules (if available)
* Compute status dynamically.
* Ensure employees without attendance records are still included.
* Add filtering support by status.

#### Notes

Clarify how “late” and “early leave” are calculated if not defined.

---

## Issue 5: Absence Recorded on Official Holidays

### Prompt

Review attendance and absence calculation logic in relation to `/official-holidays`.

#### Problem

Employees are marked as absent even on official holidays.

#### Expected Behavior

* Automatically exclude official holidays from absence calculations.

#### Requirements

* Integrate holiday data into attendance evaluation logic.
* Ensure:

  * No absence is recorded on holidays
  * Status reflects holiday if needed

#### Notes

Check timezone and date matching consistency.

---

## Issue 6: Employees on Leave Report Returns Empty

### Prompt

Investigate endpoint:
`/api/v1/attendances/dashboard/employees-on-leave`

#### Problem

The endpoint returns no data despite existing leave records.

#### Expected Behavior

* Return all employees currently on leave.

#### Requirements

* Verify leave query logic:

  * Date range filtering (current date within leave period)
* Ensure correct joins with employee data.
* Handle leave statuses (approved only).

#### Notes

Check for filtering bugs or incorrect conditions.

---

## Issue 7: Overtime Endpoint Returns No Data

### Prompt

Investigate:
`GET /api/v1/overtime?page=1`

#### Problem

No overtime records are returned.

#### Expected Behavior

* Return all overtime entries with pagination.

#### Requirements

* Verify:

  * Data existence
  * Query conditions
  * Relationships with employees
* Ensure pagination works correctly.
* Include filters if applicable.

#### Notes

Check if overtime is computed or manually stored.

---

## Issue 8: Leave Filtering Not Working

### Prompt

Analyze:
`GET /api/v1/leaves`

#### Problem

Filters are not functioning:

* Leave type
* Category
* Date

#### Expected Behavior

* All filters should work correctly.
* Date filtering should support range:

  * `from` → `to`

#### Requirements

* Fix query conditions.
* Implement proper date range filtering.
* Validate filter parameters.

#### Notes

Ensure compatibility with database indexing and performance.

---

## Issue 9: Employee ID Not Auto-Generated

### Prompt

Review employee creation logic in `/api/v1/users`.

#### Problem

Employee ID is not generated automatically.

#### Expected Behavior

* Each employee should have a unique auto-generated Employee ID.

#### Requirements

* Implement ID generation logic:

  * Sequential or formatted (e.g., EMP-001)
* Ensure uniqueness.
* Prevent manual conflicts.

#### Notes

Check concurrency handling.

---

## Issue 10: Missing Core Employee Fields

### Prompt

Analyze employee schema and endpoints in `/api/v1/users`.

#### Problem

Missing essential HR fields.

#### Expected Behavior

Add the following fields:

* Employment Status (Active / On Leave / Terminated)
* Manager ID
* Branch
* National ID / Iqama
* Audit Trail

#### Requirements

* Update database schema.
* Update create/update endpoints.
* Implement audit trail logging:

  * Track changes
  * Store timestamps and user actions

#### Notes

Audit trail should be accessible in employee details view.

---

## Issue 11: Rewards & Deductions Improvements

### Prompt

Analyze:
`GET /api/v1/rewards`

#### Problem

* No linkage between deductions and unpaid leaves
* No serial/reference numbering

#### Expected Behavior

* Each deduction linked to its source (e.g., unpaid leave)
* Generate serial numbers similar to purchase orders (e.g., PO-001)

#### Requirements

* Add reference field linking deductions to leave requests.
* Implement serial number generator.
* Apply to:

  * Leaves
  * Permissions
  * Rewards & Deductions

#### Notes

Ensure consistency across modules and uniqueness of serials.

---
