Merge pull request #6003 from neilLasrado/bug-fix
[bug fix] Fixed bug in fee caclulation, renamed functions
This commit is contained in:
commit
f979b18ddb
@ -94,13 +94,13 @@ def get_fee_structure(program, academic_term=None):
|
|||||||
return fee_structure[0].name if fee_structure else None
|
return fee_structure[0].name if fee_structure else None
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_fee_amount(fee_structure):
|
def get_fee_components(fee_structure):
|
||||||
"""Returns Fee Amount.
|
"""Returns Fee Components.
|
||||||
|
|
||||||
:param fee_structure: Fee Structure.
|
:param fee_structure: Fee Structure.
|
||||||
"""
|
"""
|
||||||
if 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
|
return fs
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
frappe.ui.form.on("Fee Amount", {
|
frappe.ui.form.on("Fee Component", {
|
||||||
amount: function(frm) {
|
amount: function(frm) {
|
||||||
total_amount = 0;
|
total_amount = 0;
|
||||||
for(var i=0;i<frm.doc.amount.length;i++) {
|
for(var i=0;i<frm.doc.components.length;i++) {
|
||||||
total_amount += frm.doc.amount[i].amount;
|
total_amount += frm.doc.components[i].amount;
|
||||||
}
|
}
|
||||||
frm.set_value("total_amount", total_amount);
|
frm.set_value("total_amount", total_amount);
|
||||||
}
|
}
|
||||||
|
@ -46,34 +46,39 @@ frappe.ui.form.on("Fees", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
fee_structure: function(frm) {
|
fee_structure: function(frm) {
|
||||||
frm.set_value("amount" ,"");
|
frm.set_value("components" ,"");
|
||||||
if (frm.doc.fee_structure) {
|
if (frm.doc.fee_structure) {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "erpnext.schools.api.get_fee_amount",
|
method: "erpnext.schools.api.get_fee_components",
|
||||||
args: {
|
args: {
|
||||||
"fee_structure": frm.doc.fee_structure
|
"fee_structure": frm.doc.fee_structure
|
||||||
},
|
},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
if (r.message) {
|
if (r.message) {
|
||||||
$.each(r.message, function(i, d) {
|
$.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.fees_category = d.fees_category;
|
||||||
row.amount = d.amount;
|
row.amount = d.amount;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
refresh_field("amount");
|
refresh_field("components");
|
||||||
|
frm.trigger("calculate_total_amount");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
});
|
|
||||||
|
calculate_total_amount: function(frm) {
|
||||||
frappe.ui.form.on("Fee Amount", {
|
|
||||||
amount: function(frm) {
|
|
||||||
total_amount = 0;
|
total_amount = 0;
|
||||||
for(var i=0;i<frm.doc.amount.length;i++) {
|
for(var i=0;i<frm.doc.components.length;i++) {
|
||||||
total_amount += frm.doc.amount[i].amount;
|
total_amount += frm.doc.components[i].amount;
|
||||||
}
|
}
|
||||||
frm.set_value("total_amount", total_amount);
|
frm.set_value("total_amount", total_amount);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
frappe.ui.form.on("Fee Component", {
|
||||||
|
amount: function(frm) {
|
||||||
|
frm.trigger("calculate_total_amount");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
@ -27,11 +27,11 @@ class ProgramEnrollment(Document):
|
|||||||
frappe.db.set_value("Student", self.student, "joining_date", date)
|
frappe.db.set_value("Student", self.student, "joining_date", date)
|
||||||
|
|
||||||
def make_fee_records(self):
|
def make_fee_records(self):
|
||||||
from erpnext.schools.api import get_fee_amount
|
from erpnext.schools.api import get_fee_components
|
||||||
fee_list = []
|
fee_list = []
|
||||||
for d in self.fees:
|
for d in self.fees:
|
||||||
fee_amount = get_fee_amount(d.fee_structure)
|
fee_components = get_fee_components(d.fee_structure)
|
||||||
if fee_amount:
|
if fee_components:
|
||||||
fees = frappe.new_doc("Fees")
|
fees = frappe.new_doc("Fees")
|
||||||
fees.update({
|
fees.update({
|
||||||
"student": self.student,
|
"student": self.student,
|
||||||
@ -42,7 +42,7 @@ class ProgramEnrollment(Document):
|
|||||||
"due_date": d.due_date,
|
"due_date": d.due_date,
|
||||||
"student_name": self.student_name,
|
"student_name": self.student_name,
|
||||||
"program_enrollment": self.name,
|
"program_enrollment": self.name,
|
||||||
"amount": fee_amount
|
"components": fee_components
|
||||||
})
|
})
|
||||||
|
|
||||||
fees.save()
|
fees.save()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user