minor changes
This commit is contained in:
parent
9b44c16a32
commit
1bcc6c661a
@ -212,18 +212,16 @@ class PaymentEntry(AccountsController):
|
|||||||
self.validate_journal_entry()
|
self.validate_journal_entry()
|
||||||
|
|
||||||
if d.reference_doctype in ("Sales Invoice", "Purchase Invoice", "Expense Claim", "Fees"):
|
if d.reference_doctype in ("Sales Invoice", "Purchase Invoice", "Expense Claim", "Fees"):
|
||||||
if self.party_type in ("Customer", "Student"):
|
if self.party_type == "Customer":
|
||||||
ref_party_account = ref_doc.debit_to
|
ref_party_account = ref_doc.debit_to
|
||||||
|
elif self.party_type == "Student":
|
||||||
|
ref_party_account = ref_doc.receivable_account
|
||||||
elif self.party_type=="Supplier":
|
elif self.party_type=="Supplier":
|
||||||
ref_party_account = ref_doc.credit_to
|
ref_party_account = ref_doc.credit_to
|
||||||
elif self.party_type=="Employee":
|
elif self.party_type=="Employee":
|
||||||
ref_party_account = ref_doc.payable_account
|
ref_party_account = ref_doc.payable_account
|
||||||
|
|
||||||
if d.reference_doctype in ("Sales Invoice", "Purchase Invoice", "Fees"):
|
if ref_party_account != self.party_account:
|
||||||
ref_party_account = ref_doc.debit_to \
|
|
||||||
if self.party_type in ("Customer", "Student") else ref_doc.credit_to
|
|
||||||
|
|
||||||
if ref_party_account != self.party_account:
|
|
||||||
frappe.throw(_("{0} {1} is associated with {2}, but Party Account is {3}")
|
frappe.throw(_("{0} {1} is associated with {2}, but Party Account is {3}")
|
||||||
.format(d.reference_doctype, d.reference_name, ref_party_account, self.party_account))
|
.format(d.reference_doctype, d.reference_name, ref_party_account, self.party_account))
|
||||||
|
|
||||||
@ -695,10 +693,12 @@ def get_payment_entry(dt, dn, party_amount=None, bank_account=None, bank_amount=
|
|||||||
party_type = "Student"
|
party_type = "Student"
|
||||||
|
|
||||||
# party account
|
# party account
|
||||||
if dt in ("Sales Invoice", "Fees"):
|
if dt == "Sales Invoice":
|
||||||
party_account = doc.debit_to
|
party_account = doc.debit_to
|
||||||
elif dt == "Purchase Invoice":
|
elif dt == "Purchase Invoice":
|
||||||
party_account = doc.credit_to
|
party_account = doc.credit_to
|
||||||
|
elif dt == "Fees":
|
||||||
|
party_account = doc.receivable_account
|
||||||
else:
|
else:
|
||||||
party_account = get_party_account(party_type, doc.get(party_type.lower()), doc.company)
|
party_account = get_party_account(party_type, doc.get(party_type.lower()), doc.company)
|
||||||
|
|
||||||
|
@ -45,6 +45,36 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"fieldname": "description",
|
||||||
|
"fieldtype": "Small Text",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"label": "Description",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"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_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
@ -107,36 +137,6 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0,
|
"unique": 0,
|
||||||
"width": "300px"
|
"width": "300px"
|
||||||
},
|
|
||||||
{
|
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "description",
|
|
||||||
"fieldtype": "Small Text",
|
|
||||||
"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": "Description",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 1,
|
|
||||||
"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
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"has_web_view": 0,
|
"has_web_view": 0,
|
||||||
@ -150,7 +150,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2017-07-18 15:03:18.945746",
|
"modified": "2017-09-11 16:48:07.810959",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Schools",
|
"module": "Schools",
|
||||||
"name": "Fee Component",
|
"name": "Fee Component",
|
||||||
|
@ -3,10 +3,39 @@
|
|||||||
|
|
||||||
frappe.ui.form.on('Fee Schedule', {
|
frappe.ui.form.on('Fee Schedule', {
|
||||||
setup: function(frm) {
|
setup: function(frm) {
|
||||||
frm.add_fetch("fee_structure", "default_receivable_account", "debit_to");
|
frm.add_fetch("fee_structure", "receivable_account", "receivable_account");
|
||||||
frm.add_fetch("fee_structure", "default_income_account", "against_income_account");
|
frm.add_fetch("fee_structure", "income_account", "income_account");
|
||||||
frm.add_fetch("fee_structure", "cost_center", "cost_center");
|
frm.add_fetch("fee_structure", "cost_center", "cost_center");
|
||||||
|
frappe.realtime.on("fee_schedule_progress", function(data) {
|
||||||
|
if (data.progress && data.progress === 0) {
|
||||||
|
frappe.msgprint(__("Fee records will be created in the background. In case of any error the error message will be updated in the Schedule."));
|
||||||
|
}
|
||||||
|
if (data.progress) {
|
||||||
|
frm.reload_doc();
|
||||||
|
frm.dashboard.add_progress("Fee Creation Status", data.progress);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
onload: function(frm) {
|
||||||
|
frm.set_query("receivable_account", function(doc) {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
'account_type': 'Receivable',
|
||||||
|
'is_group': 0,
|
||||||
|
'company': doc.company
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
frm.set_query("income_account", function(doc) {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
'account_type': 'Income Account',
|
||||||
|
'is_group': 0,
|
||||||
|
'company': doc.company
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
frm.set_query("student_group", "student_groups", function() {
|
frm.set_query("student_group", "student_groups", function() {
|
||||||
return {
|
return {
|
||||||
"program": frm.doc.program,
|
"program": frm.doc.program,
|
||||||
@ -24,7 +53,8 @@ frappe.ui.form.on('Fee Schedule', {
|
|||||||
frm.dashboard.add_indicator(__('Total Outstanding: {0}', [format_currency(info.total_unpaid,
|
frm.dashboard.add_indicator(__('Total Outstanding: {0}', [format_currency(info.total_unpaid,
|
||||||
info.currency)]), info.total_unpaid ? 'orange' : 'green');
|
info.currency)]), info.total_unpaid ? 'orange' : 'green');
|
||||||
}
|
}
|
||||||
if (!frm.doc.fee_creation_status || frm.doc.fee_creation_status == "Failed") {
|
|
||||||
|
if (!frm.doc.__islocal && !frm.doc.fee_creation_status || frm.doc.fee_creation_status == "Failed") {
|
||||||
frm.add_custom_button(__('Create Fees'), function() {
|
frm.add_custom_button(__('Create Fees'), function() {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "create_fees",
|
method: "create_fees",
|
||||||
|
@ -136,6 +136,36 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"fieldname": "send_email",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"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": "Send Email",
|
||||||
|
"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_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
@ -749,7 +779,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
"fieldname": "debit_to",
|
"fieldname": "receivable_account",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
@ -758,7 +788,7 @@
|
|||||||
"in_global_search": 0,
|
"in_global_search": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"in_standard_filter": 0,
|
"in_standard_filter": 0,
|
||||||
"label": "Academic Receivable Account",
|
"label": "Receivable Account",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"options": "Account",
|
"options": "Account",
|
||||||
@ -780,7 +810,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
"fieldname": "against_income_account",
|
"fieldname": "income_account",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
@ -999,7 +1029,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2017-09-07 12:36:02.678355",
|
"modified": "2017-09-11 16:57:27.427777",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Schools",
|
"module": "Schools",
|
||||||
"name": "Fee Schedule",
|
"name": "Fee Schedule",
|
||||||
|
@ -42,14 +42,15 @@ class FeeSchedule(Document):
|
|||||||
def create_fees(self):
|
def create_fees(self):
|
||||||
if not self.fee_creation_status or self.fee_creation_status == "Failed":
|
if not self.fee_creation_status or self.fee_creation_status == "Failed":
|
||||||
self.fee_creation_status = "In Process"
|
self.fee_creation_status = "In Process"
|
||||||
|
frappe.publish_realtime("fee_schedule_progress", {"progress": 0, "reload": True}, user=frappe.session.user)
|
||||||
enqueue(generate_fee, queue='default', timeout=6000, event='generate_fee',
|
enqueue(generate_fee, queue='default', timeout=6000, event='generate_fee',
|
||||||
fee_schedule=self.name)
|
fee_schedule=self.name)
|
||||||
frappe.msgprint(_("Fee records will be created in the background. In case of any error, the error message will be updated in the Schedule, check after refresh in 5 minutes."))
|
|
||||||
|
|
||||||
|
|
||||||
def generate_fee(fee_schedule):
|
def generate_fee(fee_schedule):
|
||||||
doc = frappe.get_doc("Fee Schedule", fee_schedule)
|
doc = frappe.get_doc("Fee Schedule", fee_schedule)
|
||||||
error = False
|
error = False
|
||||||
|
total_records = sum([int(d.total_students) for d in doc.student_groups])
|
||||||
|
created_records = 0
|
||||||
for d in doc.student_groups:
|
for d in doc.student_groups:
|
||||||
try:
|
try:
|
||||||
students = frappe.db.sql(""" select sg.program, sg.batch, sgs.student, sgs.student_name
|
students = frappe.db.sql(""" select sg.program, sg.batch, sgs.student, sgs.student_name
|
||||||
@ -74,6 +75,9 @@ def generate_fee(fee_schedule):
|
|||||||
doc.send_payment_request = 1
|
doc.send_payment_request = 1
|
||||||
doc.save()
|
doc.save()
|
||||||
doc.submit()
|
doc.submit()
|
||||||
|
created_records += 1
|
||||||
|
frappe.publish_realtime("fee_schedule_progress", {"progress": created_records}, user=frappe.session.user)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error = True
|
error = True
|
||||||
err_msg = frappe.local.message_log and "\n\n".join(frappe.local.message_log) or cstr(e)
|
err_msg = frappe.local.message_log and "\n\n".join(frappe.local.message_log) or cstr(e)
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
|
// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
cur_frm.add_fetch("company", "default_receivable_account", "debit_to");
|
|
||||||
cur_frm.add_fetch("company", "default_income_account", "against_income_account");
|
|
||||||
cur_frm.add_fetch("company", "cost_center", "cost_center");
|
|
||||||
|
|
||||||
frappe.ui.form.on('Fee Structure', {
|
frappe.ui.form.on('Fee Structure', {
|
||||||
|
setup: function(frm) {
|
||||||
|
frm.add_fetch("company", "default_receivable_account", "receivable_account");
|
||||||
|
frm.add_fetch("company", "default_income_account", "income_account");
|
||||||
|
frm.add_fetch("company", "cost_center", "cost_center");
|
||||||
|
},
|
||||||
|
|
||||||
onload: function(frm) {
|
onload: function(frm) {
|
||||||
frm.set_query("debit_to", function(doc) {
|
frm.set_query("receivable_account", function(doc) {
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
'account_type': 'Receivable',
|
'account_type': 'Receivable',
|
||||||
@ -16,6 +18,15 @@ frappe.ui.form.on('Fee Structure', {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
frm.set_query("income_account", function(doc) {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
'account_type': 'Income Account',
|
||||||
|
'is_group': 0,
|
||||||
|
'company': doc.company
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
refresh: function(frm) {
|
refresh: function(frm) {
|
||||||
|
@ -202,37 +202,6 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"default": "",
|
|
||||||
"fieldname": "disabled",
|
|
||||||
"fieldtype": "Check",
|
|
||||||
"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": "Disabled",
|
|
||||||
"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_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
@ -418,7 +387,7 @@
|
|||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
"default": "",
|
"default": "",
|
||||||
"fieldname": "debit_to",
|
"fieldname": "receivable_account",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
@ -427,7 +396,7 @@
|
|||||||
"in_global_search": 0,
|
"in_global_search": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"in_standard_filter": 0,
|
"in_standard_filter": 0,
|
||||||
"label": "Academic Receivable Account",
|
"label": "Receivable Account",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"options": "Account",
|
"options": "Account",
|
||||||
@ -449,7 +418,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
"fieldname": "against_income_account",
|
"fieldname": "income_account",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
@ -608,7 +577,7 @@
|
|||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"menu_index": 0,
|
"menu_index": 0,
|
||||||
"modified": "2017-09-07 12:04:14.807690",
|
"modified": "2017-09-11 15:18:27.975666",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Schools",
|
"module": "Schools",
|
||||||
"name": "Fee Structure",
|
"name": "Fee Structure",
|
||||||
|
@ -6,8 +6,8 @@ frappe.ui.form.on("Fees", {
|
|||||||
setup: function(frm) {
|
setup: function(frm) {
|
||||||
frm.add_fetch("student", "title", "student_name");
|
frm.add_fetch("student", "title", "student_name");
|
||||||
frm.add_fetch("student", "student_email_id", "student_email");
|
frm.add_fetch("student", "student_email_id", "student_email");
|
||||||
frm.add_fetch("fee_structure", "debit_to", "debit_to");
|
frm.add_fetch("fee_structure", "receivable_account", "receivable_account");
|
||||||
frm.add_fetch("fee_structure", "against_income_account", "against_income_account");
|
frm.add_fetch("fee_structure", "income_account", "income_account");
|
||||||
frm.add_fetch("fee_structure", "cost_center", "cost_center");
|
frm.add_fetch("fee_structure", "cost_center", "cost_center");
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -19,7 +19,6 @@ frappe.ui.form.on("Fees", {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
frm.set_query("fee_structure",function(){
|
frm.set_query("fee_structure",function(){
|
||||||
return{
|
return{
|
||||||
"filters":{
|
"filters":{
|
||||||
@ -27,9 +26,7 @@ frappe.ui.form.on("Fees", {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
frm.set_query("receivable_account", function(doc) {
|
||||||
// debit account for booking the fee
|
|
||||||
frm.set_query("debit_to", function(doc) {
|
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
'account_type': 'Receivable',
|
'account_type': 'Receivable',
|
||||||
@ -38,7 +35,15 @@ frappe.ui.form.on("Fees", {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
frm.set_query("income_account", function(doc) {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
'account_type': 'Income Account',
|
||||||
|
'is_group': 0,
|
||||||
|
'company': doc.company
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
if (!frm.doc.posting_date) {
|
if (!frm.doc.posting_date) {
|
||||||
frm.doc.posting_date = frappe.datetime.get_today();
|
frm.doc.posting_date = frappe.datetime.get_today();
|
||||||
}
|
}
|
||||||
@ -98,7 +103,7 @@ frappe.ui.form.on("Fees", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
make_payment_request: function(frm) {
|
make_payment_request: function(frm) {
|
||||||
if (!frm.doc.contact_email) {
|
if (!frm.doc.student_email) {
|
||||||
frappe.msgprint(__("Please set the Email ID for the Student to send the Payment Request"));
|
frappe.msgprint(__("Please set the Email ID for the Student to send the Payment Request"));
|
||||||
} else {
|
} else {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
@ -106,7 +111,7 @@ frappe.ui.form.on("Fees", {
|
|||||||
args: {
|
args: {
|
||||||
"dt": frm.doc.doctype,
|
"dt": frm.doc.doctype,
|
||||||
"dn": frm.doc.name,
|
"dn": frm.doc.name,
|
||||||
"recipient_id": frm.doc.contact_email
|
"recipient_id": frm.doc.student_email
|
||||||
},
|
},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
if(!r.exc){
|
if(!r.exc){
|
||||||
@ -136,23 +141,6 @@ frappe.ui.form.on("Fees", {
|
|||||||
frm.refresh();
|
frm.refresh();
|
||||||
},
|
},
|
||||||
|
|
||||||
program: function(frm) {
|
|
||||||
if (frm.doc.program && frm.doc.academic_term) {
|
|
||||||
frappe.call({
|
|
||||||
method: "erpnext.schools.api.get_fee_structure",
|
|
||||||
args: {
|
|
||||||
"program": frm.doc.program,
|
|
||||||
"academic_term": frm.doc.academic_term
|
|
||||||
},
|
|
||||||
callback: function(r) {
|
|
||||||
if(r.message) {
|
|
||||||
frm.set_value("fee_structure" ,r.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
academic_term: function() {
|
academic_term: function() {
|
||||||
frappe.ui.form.trigger("Fees", "program");
|
frappe.ui.form.trigger("Fees", "program");
|
||||||
},
|
},
|
||||||
|
@ -1146,7 +1146,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
"fieldname": "debit_to",
|
"fieldname": "receivable_account",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
@ -1155,7 +1155,7 @@
|
|||||||
"in_global_search": 0,
|
"in_global_search": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"in_standard_filter": 0,
|
"in_standard_filter": 0,
|
||||||
"label": "Academic Receivable Account",
|
"label": "Receivable Account",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"options": "Account",
|
"options": "Account",
|
||||||
@ -1177,7 +1177,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
"fieldname": "against_income_account",
|
"fieldname": "income_account",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
@ -1274,7 +1274,7 @@
|
|||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"menu_index": 0,
|
"menu_index": 0,
|
||||||
"modified": "2017-08-23 14:12:58.772381",
|
"modified": "2017-09-11 16:04:35.725204",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Schools",
|
"module": "Schools",
|
||||||
"name": "Fees",
|
"name": "Fees",
|
||||||
|
@ -11,6 +11,7 @@ from erpnext.accounts.doctype.payment_request.payment_request import make_paymen
|
|||||||
from frappe.utils.csvutils import getlink
|
from frappe.utils.csvutils import getlink
|
||||||
from erpnext.controllers.accounts_controller import AccountsController
|
from erpnext.controllers.accounts_controller import AccountsController
|
||||||
from erpnext.accounts.general_ledger import delete_gl_entries
|
from erpnext.accounts.general_ledger import delete_gl_entries
|
||||||
|
from erpnext.schools.api import get_student_guardians
|
||||||
|
|
||||||
|
|
||||||
class Fees(AccountsController):
|
class Fees(AccountsController):
|
||||||
@ -32,15 +33,27 @@ class Fees(AccountsController):
|
|||||||
self.company = frappe.defaults.get_defaults().company
|
self.company = frappe.defaults.get_defaults().company
|
||||||
if not self.currency:
|
if not self.currency:
|
||||||
self.currency = frappe.defaults.get_defaults().currency
|
self.currency = frappe.defaults.get_defaults().currency
|
||||||
if not (self.debit_to and self.against_income_account and self.cost_center):
|
if not (self.receivable_account and self.income_account and self.cost_center):
|
||||||
accounts_details = frappe.get_all("Company", fields=["default_receivable_account",
|
accounts_details = frappe.get_all("Company", fields=["default_receivable_account",
|
||||||
"default_income_account", "cost_center"], filters={"name": self.company})[0]
|
"default_income_account", "cost_center"], filters={"name": self.company})[0]
|
||||||
if not self.debit_to:
|
if not self.receivable_account:
|
||||||
self.debit_to = accounts_details.default_receivable_account
|
self.receivable_account = accounts_details.default_receivable_account
|
||||||
if not self.against_income_account:
|
if not self.income_account:
|
||||||
self.against_income_account = accounts_details.default_income_account
|
self.income_account = accounts_details.default_income_account
|
||||||
if not self.cost_center:
|
if not self.cost_center:
|
||||||
self.cost_center = accounts_details.cost_center
|
self.cost_center = accounts_details.cost_center
|
||||||
|
if not self.student_email:
|
||||||
|
self.student_email = self.get_student_emails()
|
||||||
|
|
||||||
|
def get_student_emails(self):
|
||||||
|
guardians = get_student_guardians(self.student)
|
||||||
|
email_list = []
|
||||||
|
for guardian in guardians:
|
||||||
|
email = frappe.db.get_value("Guardian", guardian.guardian, "email_address")
|
||||||
|
if email:
|
||||||
|
email_list.append(email)
|
||||||
|
return ", ".join(email_list)
|
||||||
|
|
||||||
|
|
||||||
def calculate_total(self):
|
def calculate_total(self):
|
||||||
"""Calculates total amount."""
|
"""Calculates total amount."""
|
||||||
@ -55,7 +68,7 @@ class Fees(AccountsController):
|
|||||||
self.make_gl_entries()
|
self.make_gl_entries()
|
||||||
|
|
||||||
if self.send_payment_request and self.student_email:
|
if self.send_payment_request and self.student_email:
|
||||||
pr = make_payment_request(dt="Fees", dn=self.name, recipient_id=self.contact_email,
|
pr = make_payment_request(dt="Fees", dn=self.name, recipient_id=self.student_email,
|
||||||
submit_doc=True, use_dummy_message=True)
|
submit_doc=True, use_dummy_message=True)
|
||||||
frappe.msgprint(_("Payment request {0} created").format(getlink("Payment Request", pr.name)))
|
frappe.msgprint(_("Payment request {0} created").format(getlink("Payment Request", pr.name)))
|
||||||
|
|
||||||
@ -68,17 +81,17 @@ class Fees(AccountsController):
|
|||||||
if not self.grand_total:
|
if not self.grand_total:
|
||||||
return
|
return
|
||||||
student_gl_entries = self.get_gl_dict({
|
student_gl_entries = self.get_gl_dict({
|
||||||
"account": self.debit_to,
|
"account": self.receivable_account,
|
||||||
"party_type": "Student",
|
"party_type": "Student",
|
||||||
"party": self.student,
|
"party": self.student,
|
||||||
"against": self.against_income_account,
|
"against": self.income_account,
|
||||||
"debit": self.grand_total,
|
"debit": self.grand_total,
|
||||||
"debit_in_account_currency": self.grand_total,
|
"debit_in_account_currency": self.grand_total,
|
||||||
"against_voucher": self.name,
|
"against_voucher": self.name,
|
||||||
"against_voucher_type": self.doctype
|
"against_voucher_type": self.doctype
|
||||||
})
|
})
|
||||||
fee_gl_entry = self.get_gl_dict({
|
fee_gl_entry = self.get_gl_dict({
|
||||||
"account": self.against_income_account,
|
"account": self.income_account,
|
||||||
"against": self.student,
|
"against": self.student,
|
||||||
"credit": self.grand_total,
|
"credit": self.grand_total,
|
||||||
"credit_in_account_currency": self.grand_total,
|
"credit_in_account_currency": self.grand_total,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user