Merge pull request #23333 from ruchamahabal/enrollment-fixes

fix: Program and Course Enrollment fixes
This commit is contained in:
Rucha Mahabal 2020-10-14 00:08:25 +05:30 committed by GitHub
commit 317fd06483
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 253 additions and 783 deletions

View File

@ -68,7 +68,7 @@ def make_program_and_linked_courses(program_name, course_name_list):
program = frappe.get_doc("Program", program_name) program = frappe.get_doc("Program", program_name)
course_list = [make_course(course_name) for course_name in course_name_list] course_list = [make_course(course_name) for course_name in course_name_list]
for course in course_list: for course in course_list:
program.append("courses", {"course": course}) program.append("courses", {"course": course, "required": 1})
program.save() program.save()
return program return program

View File

@ -17,9 +17,7 @@
"in_list_view": 1, "in_list_view": 1,
"label": "Course", "label": "Course",
"options": "Course", "options": "Course",
"reqd": 1, "reqd": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"fetch_from": "course.course_name", "fetch_from": "course.course_name",
@ -27,23 +25,19 @@
"fieldtype": "Data", "fieldtype": "Data",
"in_list_view": 1, "in_list_view": 1,
"label": "Course Name", "label": "Course Name",
"read_only": 1, "read_only": 1
"show_days": 1,
"show_seconds": 1
}, },
{ {
"default": "0", "default": "1",
"fieldname": "required", "fieldname": "required",
"fieldtype": "Check", "fieldtype": "Check",
"in_list_view": 1, "in_list_view": 1,
"label": "Mandatory", "label": "Mandatory"
"show_days": 1,
"show_seconds": 1
} }
], ],
"istable": 1, "istable": 1,
"links": [], "links": [],
"modified": "2020-06-09 18:56:10.213241", "modified": "2020-09-15 18:14:22.816795",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Education", "module": "Education",
"name": "Program Course", "name": "Program Course",

View File

@ -2,16 +2,24 @@
// For license information, please see license.txt // For license information, please see license.txt
frappe.ui.form.on("Program Enrollment", { frappe.ui.form.on('Program Enrollment', {
setup: function(frm) { setup: function(frm) {
frm.add_fetch('fee_structure', 'total_amount', 'amount'); frm.add_fetch('fee_structure', 'total_amount', 'amount');
}, },
onload: function(frm, cdt, cdn){ onload: function(frm) {
frm.set_query("academic_term", "fees", function(){ frm.set_query('academic_term', function() {
return { return {
"filters":{ 'filters':{
"academic_year": (frm.doc.academic_year) 'academic_year': frm.doc.academic_year
}
};
});
frm.set_query('academic_term', 'fees', function() {
return {
'filters':{
'academic_year': frm.doc.academic_year
} }
}; };
}); });
@ -24,9 +32,9 @@ frappe.ui.form.on("Program Enrollment", {
}; };
if (frm.doc.program) { if (frm.doc.program) {
frm.set_query("course", "courses", function(doc, cdt, cdn) { frm.set_query('course', 'courses', function() {
return { return {
query: "erpnext.education.doctype.program_enrollment.program_enrollment.get_program_courses", query: 'erpnext.education.doctype.program_enrollment.program_enrollment.get_program_courses',
filters: { filters: {
'program': frm.doc.program 'program': frm.doc.program
} }
@ -34,9 +42,9 @@ frappe.ui.form.on("Program Enrollment", {
}); });
} }
frm.set_query("student", function() { frm.set_query('student', function() {
return{ return{
query: "erpnext.education.doctype.program_enrollment.program_enrollment.get_students", query: 'erpnext.education.doctype.program_enrollment.program_enrollment.get_students',
filters: { filters: {
'academic_year': frm.doc.academic_year, 'academic_year': frm.doc.academic_year,
'academic_term': frm.doc.academic_term 'academic_term': frm.doc.academic_term
@ -49,14 +57,14 @@ frappe.ui.form.on("Program Enrollment", {
frm.events.get_courses(frm); frm.events.get_courses(frm);
if (frm.doc.program) { if (frm.doc.program) {
frappe.call({ frappe.call({
method: "erpnext.education.api.get_fee_schedule", method: 'erpnext.education.api.get_fee_schedule',
args: { args: {
"program": frm.doc.program, 'program': frm.doc.program,
"student_category": frm.doc.student_category 'student_category': frm.doc.student_category
}, },
callback: function(r) { callback: function(r) {
if (r.message) { if (r.message) {
frm.set_value("fees" ,r.message); frm.set_value('fees' ,r.message);
frm.events.get_courses(frm); frm.events.get_courses(frm);
} }
} }
@ -65,17 +73,17 @@ frappe.ui.form.on("Program Enrollment", {
}, },
student_category: function() { student_category: function() {
frappe.ui.form.trigger("Program Enrollment", "program"); frappe.ui.form.trigger('Program Enrollment', 'program');
}, },
get_courses: function(frm) { get_courses: function(frm) {
frm.set_value("courses",[]); frm.set_value('courses',[]);
frappe.call({ frappe.call({
method: "get_courses", method: 'get_courses',
doc:frm.doc, doc:frm.doc,
callback: function(r) { callback: function(r) {
if (r.message) { if (r.message) {
frm.set_value("courses", r.message); frm.set_value('courses', r.message);
} }
} }
}) })
@ -87,7 +95,7 @@ frappe.ui.form.on('Program Enrollment Course', {
frm.fields_dict['courses'].grid.get_field('course').get_query = function(doc) { frm.fields_dict['courses'].grid.get_field('course').get_query = function(doc) {
var course_list = []; var course_list = [];
if(!doc.__islocal) course_list.push(doc.name); if(!doc.__islocal) course_list.push(doc.name);
$.each(doc.courses, function(idx, val){ $.each(doc.courses, function(_idx, val) {
if (val.course) course_list.push(val.course); if (val.course) course_list.push(val.course);
}); });
return { filters: [['Course', 'name', 'not in', course_list]] }; return { filters: [['Course', 'name', 'not in', course_list]] };

View File

@ -1,725 +1,185 @@
{ {
"allow_copy": 0, "actions": [],
"allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 1, "allow_import": 1,
"allow_rename": 0,
"autoname": "EDU-ENR-.YYYY.-.#####", "autoname": "EDU-ENR-.YYYY.-.#####",
"beta": 0,
"creation": "2015-12-02 12:58:32.916080", "creation": "2015-12-02 12:58:32.916080",
"custom": 0,
"docstatus": 0,
"doctype": "DocType", "doctype": "DocType",
"document_type": "Document", "document_type": "Document",
"editable_grid": 0,
"engine": "InnoDB", "engine": "InnoDB",
"field_order": [
"student",
"student_name",
"student_category",
"student_batch_name",
"school_house",
"column_break_4",
"program",
"academic_year",
"academic_term",
"enrollment_date",
"boarding_student",
"enrolled_courses",
"courses",
"transportation",
"mode_of_transportation",
"column_break_13",
"vehicle_no",
"section_break_7",
"fees",
"amended_from",
"image"
],
"fields": [ "fields": [
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "student", "fieldname": "student",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 1, "in_global_search": 1,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Student", "label": "Student",
"length": 0,
"no_copy": 0,
"options": "Student", "options": "Student",
"permlevel": 0, "reqd": 1
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_from": "student.title", "fetch_from": "student.title",
"fieldname": "student_name", "fieldname": "student_name",
"fieldtype": "Read Only", "fieldtype": "Read Only",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 1, "in_global_search": 1,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Student Name", "label": "Student Name",
"length": 0, "read_only": 1
"no_copy": 0,
"options": "",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "student_category", "fieldname": "student_category",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Student Category", "label": "Student Category",
"length": 0, "options": "Student Category"
"no_copy": 0,
"options": "Student Category",
"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,
"translatable": 0,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 1, "allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "student_batch_name", "fieldname": "student_batch_name",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 1, "in_global_search": 1,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Student Batch", "label": "Student Batch",
"length": 0, "options": "Student Batch Name"
"no_copy": 0,
"options": "Student Batch Name",
"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,
"translatable": 0,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 1, "allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "school_house", "fieldname": "school_house",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "School House", "label": "School House",
"length": 0, "options": "School House"
"no_copy": 0,
"options": "School House",
"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,
"translatable": 0,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_4", "fieldname": "column_break_4",
"fieldtype": "Column Break", "fieldtype": "Column Break"
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"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,
"translatable": 0,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "program", "fieldname": "program",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 1, "in_standard_filter": 1,
"label": "Program", "label": "Program",
"length": 0,
"no_copy": 0,
"options": "Program", "options": "Program",
"permlevel": 0, "reqd": 1
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "academic_year", "fieldname": "academic_year",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 1, "in_standard_filter": 1,
"label": "Academic Year", "label": "Academic Year",
"length": 0,
"no_copy": 0,
"options": "Academic Year", "options": "Academic Year",
"permlevel": 0, "reqd": 1
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "academic_term", "fieldname": "academic_term",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Academic Term", "label": "Academic Term",
"length": 0, "options": "Academic Term"
"no_copy": 0,
"options": "Academic Term",
"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,
"translatable": 0,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "Today", "default": "Today",
"fieldname": "enrollment_date", "fieldname": "enrollment_date",
"fieldtype": "Date", "fieldtype": "Date",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Enrollment Date", "label": "Enrollment Date",
"length": 0, "reqd": 1
"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": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "0", "default": "0",
"description": "Check this if the Student is residing at the Institute's Hostel.", "description": "Check this if the Student is residing at the Institute's Hostel.",
"fieldname": "boarding_student", "fieldname": "boarding_student",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "label": "Boarding Student"
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Boarding Student",
"length": 0,
"no_copy": 0,
"options": "",
"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,
"translatable": 0,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1, "collapsible": 1,
"collapsible_depends_on": "vehicle_no", "collapsible_depends_on": "vehicle_no",
"columns": 0,
"fieldname": "transportation", "fieldname": "transportation",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "label": "Transportation"
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Transportation",
"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,
"translatable": 0,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 1, "allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "mode_of_transportation", "fieldname": "mode_of_transportation",
"fieldtype": "Select", "fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Mode of Transportation", "label": "Mode of Transportation",
"length": 0, "options": "\nWalking\nInstitute's Bus\nPublic Transport\nSelf-Driving Vehicle\nPick/Drop by Guardian"
"no_copy": 0,
"options": "\nWalking\nInstitute's Bus\nPublic Transport\nSelf-Driving Vehicle\nPick/Drop by Guardian",
"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,
"translatable": 0,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_13", "fieldname": "column_break_13",
"fieldtype": "Column Break", "fieldtype": "Column Break"
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"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,
"translatable": 0,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 1, "allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "vehicle_no", "fieldname": "vehicle_no",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 0, "label": "Vehicle/Bus Number"
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Vehicle/Bus Number",
"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,
"translatable": 0,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
"columns": 0,
"fieldname": "enrolled_courses", "fieldname": "enrolled_courses",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "label": "Enrolled courses"
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Enrolled courses",
"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,
"translatable": 0,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 1, "allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "courses", "fieldname": "courses",
"fieldtype": "Table", "fieldtype": "Table",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Courses", "label": "Courses",
"length": 0, "options": "Program Enrollment Course"
"no_copy": 0,
"options": "Program Enrollment Course",
"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,
"translatable": 0,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1, "collapsible": 1,
"columns": 0,
"fieldname": "section_break_7", "fieldname": "section_break_7",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "label": "Fees"
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Fees",
"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,
"translatable": 0,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "fees", "fieldname": "fees",
"fieldtype": "Table", "fieldtype": "Table",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Fees", "label": "Fees",
"length": 0, "options": "Program Fee"
"no_copy": 0,
"options": "Program Fee",
"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,
"translatable": 0,
"unique": 0,
"width": ""
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "amended_from", "fieldname": "amended_from",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Amended From", "label": "Amended From",
"length": 0,
"no_copy": 1, "no_copy": 1,
"options": "Program Enrollment", "options": "Program Enrollment",
"permlevel": 0,
"print_hide": 1, "print_hide": 1,
"print_hide_if_no_value": 0, "read_only": 1
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "image", "fieldname": "image",
"fieldtype": "Attach Image", "fieldtype": "Attach Image",
"hidden": 1, "hidden": 1,
"ignore_user_permissions": 0, "label": "Image"
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Image",
"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,
"translatable": 0,
"unique": 0
} }
], ],
"has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"idx": 0,
"image_field": "image", "image_field": "image",
"image_view": 0,
"in_create": 0,
"is_submittable": 1, "is_submittable": 1,
"issingle": 0, "links": [],
"istable": 0, "modified": "2020-09-15 18:12:11.988565",
"max_attachments": 0,
"menu_index": 0,
"modified": "2018-11-07 21:13:06.502279",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Education", "module": "Education",
"name": "Program Enrollment", "name": "Program Enrollment",
"name_case": "",
"owner": "Administrator", "owner": "Administrator",
"permissions": [ "permissions": [
{ {
@ -729,47 +189,30 @@
"delete": 1, "delete": 1,
"email": 1, "email": 1,
"export": 1, "export": 1,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1, "print": 1,
"read": 1, "read": 1,
"report": 1, "report": 1,
"role": "Academics User", "role": "Academics User",
"set_user_permissions": 0,
"share": 1, "share": 1,
"submit": 1, "submit": 1,
"write": 1 "write": 1
}, },
{ {
"amend": 0,
"cancel": 0,
"create": 1, "create": 1,
"delete": 0,
"email": 1, "email": 1,
"export": 1, "export": 1,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1, "print": 1,
"read": 1, "read": 1,
"report": 1, "report": 1,
"role": "LMS User", "role": "LMS User",
"set_user_permissions": 0,
"share": 1, "share": 1,
"submit": 1, "submit": 1,
"write": 1 "write": 1
} }
], ],
"quick_entry": 0,
"read_only": 0,
"read_only_onload": 0,
"restrict_to_domain": "Education", "restrict_to_domain": "Education",
"show_name_in_global_search": 1, "show_name_in_global_search": 1,
"sort_field": "modified", "sort_field": "modified",
"sort_order": "DESC", "sort_order": "DESC",
"title_field": "student_name", "title_field": "student_name"
"track_changes": 0,
"track_seen": 0,
"track_views": 0
} }

View File

@ -7,12 +7,15 @@ import frappe
from frappe import msgprint, _ from frappe import msgprint, _
from frappe.model.document import Document from frappe.model.document import Document
from frappe.desk.reportview import get_match_cond, get_filters_cond from frappe.desk.reportview import get_match_cond, get_filters_cond
from frappe.utils import comma_and from frappe.utils import comma_and, get_link_to_form, getdate
import erpnext.www.lms as lms import erpnext.www.lms as lms
class ProgramEnrollment(Document): class ProgramEnrollment(Document):
def validate(self): def validate(self):
self.validate_duplication() self.validate_duplication()
self.validate_academic_year()
if self.academic_term:
self.validate_academic_term()
if not self.student_name: if not self.student_name:
self.student_name = frappe.db.get_value("Student", self.student, "title") self.student_name = frappe.db.get_value("Student", self.student, "title")
if not self.courses: if not self.courses:
@ -23,11 +26,34 @@ class ProgramEnrollment(Document):
self.make_fee_records() self.make_fee_records()
self.create_course_enrollments() self.create_course_enrollments()
def validate_academic_year(self):
start_date, end_date = frappe.db.get_value("Academic Year", self.academic_year, ["year_start_date", "year_end_date"])
if self.enrollment_date:
if start_date and getdate(self.enrollment_date) < getdate(start_date):
frappe.throw(_("Enrollment Date cannot be before the Start Date of the Academic Year {0}").format(
get_link_to_form("Academic Year", self.academic_year)))
if end_date and getdate(self.enrollment_date) > getdate(end_date):
frappe.throw(_("Enrollment Date cannot be after the End Date of the Academic Term {0}").format(
get_link_to_form("Academic Year", self.academic_year)))
def validate_academic_term(self):
start_date, end_date = frappe.db.get_value("Academic Term", self.academic_term, ["term_start_date", "term_end_date"])
if self.enrollment_date:
if start_date and getdate(self.enrollment_date) < getdate(start_date):
frappe.throw(_("Enrollment Date cannot be before the Start Date of the Academic Term {0}").format(
get_link_to_form("Academic Term", self.academic_term)))
if end_date and getdate(self.enrollment_date) > getdate(end_date):
frappe.throw(_("Enrollment Date cannot be after the End Date of the Academic Term {0}").format(
get_link_to_form("Academic Term", self.academic_term)))
def validate_duplication(self): def validate_duplication(self):
enrollment = frappe.get_all("Program Enrollment", filters={ enrollment = frappe.get_all("Program Enrollment", filters={
"student": self.student, "student": self.student,
"program": self.program, "program": self.program,
"academic_year": self.academic_year, "academic_year": self.academic_year,
"academic_term": self.academic_term,
"docstatus": ("<", 2), "docstatus": ("<", 2),
"name": ("!=", self.name) "name": ("!=", self.name)
}) })
@ -70,10 +96,9 @@ class ProgramEnrollment(Document):
def create_course_enrollments(self): def create_course_enrollments(self):
student = frappe.get_doc("Student", self.student) student = frappe.get_doc("Student", self.student)
program = frappe.get_doc("Program", self.program) course_list = [course.course for course in self.courses]
course_list = [course.course for course in program.courses]
for course_name in course_list: for course_name in course_list:
student.enroll_in_course(course_name=course_name, program_enrollment=self.name) student.enroll_in_course(course_name=course_name, program_enrollment=self.name, enrollment_date=self.enrollment_date)
def get_all_course_enrollments(self): def get_all_course_enrollments(self):
course_enrollment_names = frappe.get_list("Course Enrollment", filters={'program_enrollment': self.name}) course_enrollment_names = frappe.get_list("Course Enrollment", filters={'program_enrollment': self.name})