[bug fix] Fixed bug in fee caclulation, renamed functions
diff --git a/erpnext/schools/api.py b/erpnext/schools/api.py
index 26577b4..4649d0c 100644
--- a/erpnext/schools/api.py
+++ b/erpnext/schools/api.py
@@ -94,13 +94,13 @@
return fee_structure[0].name if fee_structure else None
@frappe.whitelist()
-def get_fee_amount(fee_structure):
- """Returns Fee Amount.
+def get_fee_components(fee_structure):
+ """Returns Fee Components.
:param fee_structure: Fee Structure.
"""
if fee_structure:
- fs = frappe.get_list("Fee Amount", fields=["fees_category", "amount"] , filters={"parent": fee_structure}, order_by= "idx")
+ fs = frappe.get_list("Fee Component", fields=["fees_category", "amount"] , filters={"parent": fee_structure}, order_by= "idx")
return fs
@frappe.whitelist()
diff --git a/erpnext/schools/doctype/fee_structure/fee_structure.js b/erpnext/schools/doctype/fee_structure/fee_structure.js
index e3d4544..391c935 100644
--- a/erpnext/schools/doctype/fee_structure/fee_structure.js
+++ b/erpnext/schools/doctype/fee_structure/fee_structure.js
@@ -1,8 +1,8 @@
-frappe.ui.form.on("Fee Amount", {
+frappe.ui.form.on("Fee Component", {
amount: function(frm) {
total_amount = 0;
- for(var i=0;i<frm.doc.amount.length;i++) {
- total_amount += frm.doc.amount[i].amount;
+ for(var i=0;i<frm.doc.components.length;i++) {
+ total_amount += frm.doc.components[i].amount;
}
frm.set_value("total_amount", total_amount);
}
diff --git a/erpnext/schools/doctype/fees/fees.js b/erpnext/schools/doctype/fees/fees.js
index 0e9ad76..22c6d8a 100644
--- a/erpnext/schools/doctype/fees/fees.js
+++ b/erpnext/schools/doctype/fees/fees.js
@@ -46,34 +46,39 @@
},
fee_structure: function(frm) {
- frm.set_value("amount" ,"");
+ frm.set_value("components" ,"");
if (frm.doc.fee_structure) {
frappe.call({
- method: "erpnext.schools.api.get_fee_amount",
+ method: "erpnext.schools.api.get_fee_components",
args: {
"fee_structure": frm.doc.fee_structure
},
callback: function(r) {
if (r.message) {
$.each(r.message, function(i, d) {
- var row = frappe.model.add_child(frm.doc, "Fee Amount", "amount");
+ var row = frappe.model.add_child(frm.doc, "Fee Component", "components");
row.fees_category = d.fees_category;
row.amount = d.amount;
});
}
- refresh_field("amount");
+ refresh_field("components");
+ frm.trigger("calculate_total_amount");
}
});
}
+ },
+
+ calculate_total_amount: function(frm) {
+ total_amount = 0;
+ for(var i=0;i<frm.doc.components.length;i++) {
+ total_amount += frm.doc.components[i].amount;
+ }
+ frm.set_value("total_amount", total_amount);
}
});
-frappe.ui.form.on("Fee Amount", {
+frappe.ui.form.on("Fee Component", {
amount: function(frm) {
- total_amount = 0;
- for(var i=0;i<frm.doc.amount.length;i++) {
- total_amount += frm.doc.amount[i].amount;
- }
- frm.set_value("total_amount", total_amount);
+ frm.trigger("calculate_total_amount");
}
});
diff --git a/erpnext/schools/doctype/program_enrollment/program_enrollment.py b/erpnext/schools/doctype/program_enrollment/program_enrollment.py
index ca193dd..a15a070 100644
--- a/erpnext/schools/doctype/program_enrollment/program_enrollment.py
+++ b/erpnext/schools/doctype/program_enrollment/program_enrollment.py
@@ -27,11 +27,11 @@
frappe.db.set_value("Student", self.student, "joining_date", date)
def make_fee_records(self):
- from erpnext.schools.api import get_fee_amount
+ from erpnext.schools.api import get_fee_components
fee_list = []
for d in self.fees:
- fee_amount = get_fee_amount(d.fee_structure)
- if fee_amount:
+ fee_components = get_fee_components(d.fee_structure)
+ if fee_components:
fees = frappe.new_doc("Fees")
fees.update({
"student": self.student,
@@ -42,7 +42,7 @@
"due_date": d.due_date,
"student_name": self.student_name,
"program_enrollment": self.name,
- "amount": fee_amount
+ "components": fee_components
})
fees.save()