Skip to content

Commit

Permalink
fix: show attendance w.r.t years instead of academic year
Browse files Browse the repository at this point in the history
  • Loading branch information
RitvikSardana committed Mar 12, 2024
1 parent 64a028f commit bf5596a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ frappe.query_reports["Student Monthly Attendance Sheet"] = {
{
"fieldname": "year",
"label": __("Year"),
"fieldtype": "Link",
"options":"Academic Year",
"fieldtype": "Select",
"options":"",
"reqd": 1
},
{
Expand All @@ -27,4 +27,17 @@ frappe.query_reports["Student Monthly Attendance Sheet"] = {
"reqd": 1
}
],
onload: function() {
return frappe.call({
// method: "hrms.hr.report.monthly_attendance_sheet.monthly_attendance_sheet.get_attendance_years",
method: "education.education.report.student_monthly_attendance_sheet.student_monthly_attendance_sheet.get_year_list",
callback: function(r) {
let year_filter = frappe.query_report.get_filter('year');
year_filter.df.options = r.message;
year_filter.df.default = r.message.join("\n");
year_filter.refresh();
year_filter.set_input(year_filter.df.default);
}
});
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,15 @@ def execute(filters=None):
if not filters:
filters = {}

filter_year = str(
frappe.db.get_value(
"Academic Year", {"name": filters["year"]}, fieldname="year_start_date"
).year
)

from_date = get_first_day(filters["month"] + "-" + filter_year)
to_date = get_last_day(filters["month"] + "-" + filter_year)

from_date = get_first_day(filters["month"] + "-" + filters["year"])
to_date = get_last_day(filters["month"] + "-" + filters["year"])
total_days_in_month = date_diff(to_date, from_date) + 1
columns = get_columns(total_days_in_month)
students = get_student_group_students(filters.get("student_group"), 1)
students_list = get_students_list(students)
att_map = get_attendance_list(
from_date, to_date, filters.get("student_group"), students_list
)
print(att_map)
data = []

for stud in students:
Expand Down Expand Up @@ -69,7 +61,6 @@ def execute(filters=None):

row += [total_p, total_a]
data.append(row)
print(data)
return columns, data


Expand Down Expand Up @@ -161,3 +152,14 @@ def mark_holidays(att_map, from_date, to_date, students_list):
att_map.setdefault(student, frappe._dict()).setdefault(dt, "Holiday")

return att_map


@frappe.whitelist()
def get_year_list():
all_academic_years = frappe.db.get_list("Academic Year", pluck="year_start_date")

year_list = [date.year for date in all_academic_years]
year_list = list(set(year_list))
year_list.sort()

return year_list

0 comments on commit bf5596a

Please sign in to comment.