اشرح لي الدالة التي سوف ارسلها لك
- User
اشرح لي الدالة التي سوف ارسلها لك
- Assistant
بالطبع، أرسل الدالة وسأشرحها لك بالتفصيل!
- User
@frappe.whitelist()
def check_missing_records(timesheet_tool_name): """ Check if there are employees without Timesheets or Additional Salaries incomplete in timesheet_tool_details. """ missing_records = False# Retrieval of staff details from the schedule_tool_details timesheet_tool_details = frappe.db.get_all( "Timesheet Tool Details", filters={"parent": timesheet_tool_name}, fields=["employee", "hour", "over_time_h", "over_time_n", "deduction"] ) for detail in timesheet_tool_details: employee = detail.get("employee") hour = detail.get("hour") over_time_h = detail.get("over_time_h") over_time_n = detail.get("over_time_n") deduction = detail.get("deduction") # Check the missing timesheet records. if hour and hour > 0: timesheet_exists = frappe.db.exists( "Timesheet", {"employee": employee, "timesheet_tool": timesheet_tool_name} ) if not timesheet_exists: missing_records = True continue # Verification of missing records of Additional Salary additional_salary_filters = [ (over_time_h, "Overtime H", ">", 0), (over_time_n, "Overtime N", ">", 0), (deduction, "Deduction", ">", 0) ] for value, salary_component, operator, target in additional_salary_filters: if value and eval(f"value {operator} target"): # A dynamic assessment of the condition additional_salary_exists = frappe.db.exists( "Additional Salary", { "employee": employee, "timesheet_tool": timesheet_tool_name, "salary_component": salary_component } ) if not additional_salary_exists: missing_records = True continue return "missing" if missing_records else "complete" - Assistant
- User
Verification of missing records of Additional Salary
additional_salary_filters = [ (over_time_h, "Overtime H", ">", 0), (over_time_n, "Overtime N", ">", 0), (deduction, "Deduction", ">", 0) ] for value, salary_component, operator, target in additional_salary_filters: if value and eval(f"value {operator} target"): # A dynamic assessment of the condition additional_salary_exists = frappe.db.exists( "Additional Salary", { "employee": employee, "timesheet_tool": timesheet_tool_name, "salary_component": salary_component } ) if not additional_salary_exists: missing_records = True continue - Assistant
- User
هذا الجزاء لا يعمل بشكل صحيح
- Assistant
- User
salary_component اريد ان يتم جلبة من دكتايب Timesheet Tool Setting من الحقول "salary_component_overtime_n, salary_component_overtime_h, salary_component_deduction"
- Assistant
- User
شكراً لك
- Assistant
على الرحب والسعة! 😊 إذا احتجت إلى أي مساعدة إضافية في المستقبل، فلا تتردد في السؤال. أتمنى لك التوفيق في مشروعك! 🚀
بالتوفيق دائمًا! 🙏✨
- User
الان لدي الدالة check_missing_records_for_approval ولتي سوف ارسل لك الكود الخاص بها هذه الداله الية عملها مثل الدالة check_missing_records الاختلف هو ان الدالة check_missing_records_for_approval تتحقق من اذا وجدت سجلات غير معتمدة بنفس اليه التحقق في الدالة check_missing_records التي تتحقق من انشاء جميع السجلات فالدالة check_missing_records_for_approval تتحقق من اذا كانت جميع السجلات معتمدة
- Assistant
- User
@frappe.whitelist() def check_missing_records_for_approval(timesheet_tool_name): """ Check if all associated records (Timesheets Additional Salaries) have been approved. """ incomplete_records = False
# Check out the unapproved Timesheet incomplete_timesheets = frappe.db.get_all( "Timesheet", filters={"timesheet_tool": timesheet_tool_name, "docstatus": ["=", 0]}, fields=["name"] ) if incomplete_timesheets: incomplete_records = True # Verification of additional certified salaries incomplete_additional_salaries = frappe.db.get_all( "Additional Salary", filters={"timesheet_tool": timesheet_tool_name, "docstatus": ["=", 0]}, fields=["name"] ) if incomplete_additional_salaries: incomplete_records = True return "missing" if incomplete_records else "complete" - Assistant
- User
اريد منك الان ان تقوم بتعديل الدلة check_missing_records_for_approval للعمل بنفس الية عمل الداة check_missing_records
- Assistant
- User
- Assistant
- User
الزر Create Attendance يعمل بشكل جيد ولا توجد فيه اي مشاكل انما الزر Approval Attendance يضل معطل
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.