From 9a7cb6ce927ae3dd1ace37664117ec3bed17d596 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Tue, 20 Dec 2016 18:06:04 +0530 Subject: [PATCH] Added mark as present to student leave application --- .../student_leave_application.json | 30 ++++++++++++++++++- .../student_monthly_attendance_sheet.py | 22 +++++++++++--- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/erpnext/schools/doctype/student_leave_application/student_leave_application.json b/erpnext/schools/doctype/student_leave_application/student_leave_application.json index f183afc442..2a8dfb24cd 100644 --- a/erpnext/schools/doctype/student_leave_application/student_leave_application.json +++ b/erpnext/schools/doctype/student_leave_application/student_leave_application.json @@ -126,6 +126,34 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "mark_as_present", + "fieldtype": "Check", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Mark as Present", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_on_submit": 0, "bold": 0, @@ -220,7 +248,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2016-12-15 14:51:28.774955", + "modified": "2016-12-20 15:08:40.750278", "modified_by": "Administrator", "module": "Schools", "name": "Student Leave Application", diff --git a/erpnext/schools/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.py b/erpnext/schools/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.py index 2f8ba52378..025e078c21 100644 --- a/erpnext/schools/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.py +++ b/erpnext/schools/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.py @@ -51,26 +51,40 @@ def get_attendance_list(conditions, filters): status from `tabStudent Attendance` where docstatus = 1 %s order by student, date""" % conditions, filters, as_dict=1) + students_with_leave_application = get_students_with_leave_application(filters) + att_map = {} for d in attendance_list: att_map.setdefault(d.student, frappe._dict()).setdefault(d.day_of_month, "") - att_map[d.student][d.day_of_month] = d.status + for stud in students_with_leave_application: + if stud.student== d.student and stud.day_of_month== d.day_of_month: + att_map[d.student][d.day_of_month] = "Present" + break + else: + att_map[d.student][d.day_of_month] = d.status return att_map +def get_students_with_leave_application(filters): + students_with_leave_application = frappe.db.sql("""select student, day(date) as day_of_month + from `tabStudent Leave Application` where mark_as_present and docstatus = 1 + and month(date) = %(month)s and year(date) = %(year)s + order by student, date""", filters, as_dict=1) + return students_with_leave_application + def get_conditions(filters): if not (filters.get("month") and filters.get("year")): msgprint(_("Please select month and year"), raise_exception=1) - + filters["month"] = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"].index(filters.month) + 1 filters["total_days_in_month"] = monthrange(cint(filters.year), filters.month)[1] - + conditions = " and month(date) = %(month)s and year(date) = %(year)s" if filters.get("student_batch"): conditions += " and student_batch = %(student_batch)s" - + return conditions, filters @frappe.whitelist()