mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 03:09:09 +00:00
Fixes related to schools fees
This commit is contained in:
@@ -62,10 +62,8 @@ frappe.ui.form.on('Fee Schedule', {
|
|||||||
if (frm.doc.fee_creation_status=="In Process") {
|
if (frm.doc.fee_creation_status=="In Process") {
|
||||||
frm.dashboard.add_progress("Fee Creation Status", "0");
|
frm.dashboard.add_progress("Fee Creation Status", "0");
|
||||||
}
|
}
|
||||||
if (!frm.doc.__islocal && !frm.doc.fee_creation_status || frm.doc.fee_creation_status == "Failed") {
|
if (frm.doc.docstatus==1 && !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() {
|
||||||
frm.doc.fee_creation_status = "In Process";
|
|
||||||
frm.save();
|
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "create_fees",
|
method: "create_fees",
|
||||||
doc: frm.doc,
|
doc: frm.doc,
|
||||||
@@ -75,9 +73,6 @@ frappe.ui.form.on('Fee Schedule', {
|
|||||||
});
|
});
|
||||||
}, "fa fa-play", "btn-success");
|
}, "fa fa-play", "btn-success");
|
||||||
}
|
}
|
||||||
if (frm.doc.fee_creation_status==="Successful") {
|
|
||||||
frm.set_read_only();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
fee_structure: function(frm) {
|
fee_structure: function(frm) {
|
||||||
@@ -104,6 +99,8 @@ frappe.ui.form.on("Fee Schedule Student Group", {
|
|||||||
method: "erpnext.schools.doctype.fee_schedule.fee_schedule.get_total_students",
|
method: "erpnext.schools.doctype.fee_schedule.fee_schedule.get_total_students",
|
||||||
args: {
|
args: {
|
||||||
"student_group": row.student_group,
|
"student_group": row.student_group,
|
||||||
|
"academic_year": frm.doc.academic_year,
|
||||||
|
"academic_term": frm.doc.academic_term,
|
||||||
"student_category": frm.doc.student_category
|
"student_category": frm.doc.student_category
|
||||||
},
|
},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"allow_copy": 0,
|
"allow_copy": 0,
|
||||||
"allow_guest_to_view": 0,
|
"allow_guest_to_view": 0,
|
||||||
"allow_import": 0,
|
"allow_import": 1,
|
||||||
"allow_rename": 0,
|
"allow_rename": 0,
|
||||||
"autoname": "naming_series:",
|
"autoname": "naming_series:",
|
||||||
"beta": 1,
|
"beta": 1,
|
||||||
@@ -151,7 +151,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": "Send Email",
|
"label": "Send Payment Request Email",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
@@ -1025,11 +1025,11 @@
|
|||||||
"idx": 0,
|
"idx": 0,
|
||||||
"image_view": 0,
|
"image_view": 0,
|
||||||
"in_create": 0,
|
"in_create": 0,
|
||||||
"is_submittable": 0,
|
"is_submittable": 1,
|
||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2017-09-12 02:03:37.062064",
|
"modified": "2017-09-19 16:24:17.266071",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Schools",
|
"module": "Schools",
|
||||||
"name": "Fee Schedule",
|
"name": "Fee Schedule",
|
||||||
@@ -1037,23 +1037,23 @@
|
|||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
{
|
{
|
||||||
"amend": 0,
|
"amend": 1,
|
||||||
"apply_user_permissions": 0,
|
"apply_user_permissions": 0,
|
||||||
"cancel": 0,
|
"cancel": 1,
|
||||||
"create": 1,
|
"create": 1,
|
||||||
"delete": 1,
|
"delete": 1,
|
||||||
"email": 1,
|
"email": 1,
|
||||||
"export": 0,
|
"export": 1,
|
||||||
"if_owner": 0,
|
"if_owner": 0,
|
||||||
"import": 0,
|
"import": 1,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print": 1,
|
"print": 1,
|
||||||
"read": 1,
|
"read": 1,
|
||||||
"report": 0,
|
"report": 1,
|
||||||
"role": "Academics User",
|
"role": "Academics User",
|
||||||
"set_user_permissions": 0,
|
"set_user_permissions": 0,
|
||||||
"share": 1,
|
"share": 1,
|
||||||
"submit": 0,
|
"submit": 1,
|
||||||
"write": 1
|
"write": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe, erpnext
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
from frappe.utils import money_in_words
|
from frappe.utils import money_in_words
|
||||||
@@ -17,13 +17,19 @@ class FeeSchedule(Document):
|
|||||||
self.set_onload('dashboard_info', info)
|
self.set_onload('dashboard_info', info)
|
||||||
|
|
||||||
def get_dashboard_info(self):
|
def get_dashboard_info(self):
|
||||||
total_unpaid = frappe.db.sql("""select sum(outstanding_amount) from tabFees
|
info = {
|
||||||
where fee_schedule=%s""", (self.name))
|
"total_paid": 0,
|
||||||
total_unpaid_amount = flt(total_unpaid[0][0]) if total_unpaid else 0
|
"total_unpaid": 0,
|
||||||
info = {}
|
"currency": erpnext.get_company_currency(self.company)
|
||||||
info["total_paid"] = self.grand_total - total_unpaid_amount
|
}
|
||||||
info["total_unpaid"] = total_unpaid_amount
|
|
||||||
info["currency"] = frappe.defaults.get_defaults().currency
|
fees_amount = frappe.db.sql("""select sum(grand_total), sum(outstanding_amount) from tabFees
|
||||||
|
where fee_schedule=%s and docstatus=1""", (self.name))
|
||||||
|
|
||||||
|
if fees_amount:
|
||||||
|
info["total_paid"] = flt(fees_amount[0][0]) - flt(fees_amount[0][1])
|
||||||
|
info["total_unpaid"] = flt(fees_amount[0][1])
|
||||||
|
|
||||||
return info
|
return info
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
@@ -33,16 +39,18 @@ class FeeSchedule(Document):
|
|||||||
no_of_students = 0
|
no_of_students = 0
|
||||||
for d in self.student_groups:
|
for d in self.student_groups:
|
||||||
# if not d.total_students:
|
# if not d.total_students:
|
||||||
d.total_students = get_total_students(d.student_group, self.student_category)
|
d.total_students = get_total_students(d.student_group, self.academic_year,
|
||||||
|
self.academic_term, self.student_category)
|
||||||
no_of_students += cint(d.total_students)
|
no_of_students += cint(d.total_students)
|
||||||
self.grand_total = no_of_students*self.total_amount
|
self.grand_total = no_of_students*self.total_amount
|
||||||
self.grand_total_in_words = money_in_words(self.grand_total)
|
self.grand_total_in_words = money_in_words(self.grand_total)
|
||||||
|
|
||||||
def create_fees(self):
|
def create_fees(self):
|
||||||
if self.fee_creation_status == "In Process":
|
self.db_set("fee_creation_status", "In Process")
|
||||||
frappe.publish_realtime("fee_schedule_progress", {"progress": "0", "reload": 1}, user=frappe.session.user)
|
frappe.publish_realtime("fee_schedule_progress",
|
||||||
enqueue(generate_fee, queue='default', timeout=6000, event='generate_fee',
|
{"progress": "0", "reload": 1}, user=frappe.session.user)
|
||||||
fee_schedule=self.name)
|
enqueue(generate_fee, queue='default', timeout=6000, event='generate_fee',
|
||||||
|
fee_schedule=self.name)
|
||||||
|
|
||||||
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)
|
||||||
@@ -87,7 +95,8 @@ def generate_fee(fee_schedule):
|
|||||||
frappe.db.set_value("Fee Schedule", fee_schedule, "fee_creation_status", "Successful")
|
frappe.db.set_value("Fee Schedule", fee_schedule, "fee_creation_status", "Successful")
|
||||||
frappe.db.set_value("Fee Schedule", fee_schedule, "error_log", None)
|
frappe.db.set_value("Fee Schedule", fee_schedule, "error_log", None)
|
||||||
|
|
||||||
frappe.publish_realtime("fee_schedule_progress", {"progress": "100", "reload": 1}, user=frappe.session.user)
|
frappe.publish_realtime("fee_schedule_progress",
|
||||||
|
{"progress": "100", "reload": 1}, user=frappe.session.user)
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
@@ -99,17 +108,21 @@ def get_fee_structure(source_name,target_doc=None):
|
|||||||
return fee_request
|
return fee_request
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_total_students(student_group, student_category=None):
|
def get_total_students(student_group, academic_year, academic_term=None, student_category=None):
|
||||||
conditions = ""
|
conditions = ""
|
||||||
if student_category:
|
if student_category:
|
||||||
conditions = " and s.student_category='{}'".format(frappe.db.escape(student_category))
|
conditions = " and pe.student_category='{}'".format(frappe.db.escape(student_category))
|
||||||
|
if academic_term:
|
||||||
|
conditions = " and pe.academic_term='{}'".format(frappe.db.escape(academic_term))
|
||||||
|
|
||||||
|
|
||||||
return frappe.db.sql("""
|
return frappe.db.sql("""
|
||||||
select count(s.name)
|
select count(pe.name)
|
||||||
from `tabStudent` s, `tabStudent Group Student` sgs
|
from `tabStudent Group Student` sgs, `tabProgram Enrollment` pe
|
||||||
where
|
where
|
||||||
s.name = sgs.student
|
pe.student = sgs.student
|
||||||
|
and pe.academic_year = %s
|
||||||
and sgs.parent = %s
|
and sgs.parent = %s
|
||||||
and sgs.active = 1
|
and sgs.active = 1
|
||||||
{conditions}
|
{conditions}
|
||||||
""".format(conditions=conditions), student_group)[0][0]
|
""".format(conditions=conditions), (academic_year, student_group))[0][0]
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
|
|
||||||
frappe.ui.form.on("Fees", {
|
frappe.ui.form.on("Fees", {
|
||||||
setup: function(frm) {
|
setup: function(frm) {
|
||||||
frm.add_fetch("student", "title", "student_name");
|
|
||||||
frm.add_fetch("student", "student_email_id", "student_email");
|
|
||||||
frm.add_fetch("fee_structure", "receivable_account", "receivable_account");
|
frm.add_fetch("fee_structure", "receivable_account", "receivable_account");
|
||||||
frm.add_fetch("fee_structure", "income_account", "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");
|
||||||
|
|||||||
@@ -93,6 +93,7 @@
|
|||||||
"label": "Student Name",
|
"label": "Student Name",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
|
"options": "student.student_name",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
@@ -136,37 +137,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": "send_payment_request",
|
|
||||||
"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 Payment Request",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 1,
|
|
||||||
"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,
|
||||||
@@ -198,6 +168,37 @@
|
|||||||
"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": "send_payment_request",
|
||||||
|
"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 Payment Request",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 1,
|
||||||
|
"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,
|
||||||
@@ -505,13 +506,14 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 1,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"depends_on": "",
|
||||||
"fieldname": "student_email",
|
"fieldname": "student_email",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"hidden": 1,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
"ignore_xss_filter": 0,
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
@@ -526,7 +528,7 @@
|
|||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"print_hide_if_no_value": 0,
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 1,
|
"read_only": 0,
|
||||||
"remember_last_selected_value": 0,
|
"remember_last_selected_value": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@@ -1274,7 +1276,7 @@
|
|||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"menu_index": 0,
|
"menu_index": 0,
|
||||||
"modified": "2017-09-11 16:04:35.725204",
|
"modified": "2017-09-19 16:45:14.313744",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Schools",
|
"module": "Schools",
|
||||||
"name": "Fees",
|
"name": "Fees",
|
||||||
|
|||||||
@@ -4,14 +4,13 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
import frappe
|
import frappe, erpnext
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import money_in_words
|
from frappe.utils import money_in_words
|
||||||
from erpnext.accounts.doctype.payment_request.payment_request import make_payment_request
|
from erpnext.accounts.doctype.payment_request.payment_request import make_payment_request
|
||||||
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,10 +31,11 @@ class Fees(AccountsController):
|
|||||||
if not self.company:
|
if not self.company:
|
||||||
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 = erpnext.get_company_currency(self.company)
|
||||||
if not (self.receivable_account and self.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",
|
||||||
"default_income_account", "cost_center"], filters={"name": self.company})[0]
|
fields=["default_receivable_account", "default_income_account", "cost_center"],
|
||||||
|
filters={"name": self.company})[0]
|
||||||
if not self.receivable_account:
|
if not self.receivable_account:
|
||||||
self.receivable_account = accounts_details.default_receivable_account
|
self.receivable_account = accounts_details.default_receivable_account
|
||||||
if not self.income_account:
|
if not self.income_account:
|
||||||
@@ -46,13 +46,14 @@ class Fees(AccountsController):
|
|||||||
self.student_email = self.get_student_emails()
|
self.student_email = self.get_student_emails()
|
||||||
|
|
||||||
def get_student_emails(self):
|
def get_student_emails(self):
|
||||||
guardians = get_student_guardians(self.student)
|
student_emails = frappe.db.sql_list("""
|
||||||
email_list = []
|
select g.email_address
|
||||||
for guardian in guardians:
|
from `tabGuardian` g, `tabStudent Guardian` sg
|
||||||
email = frappe.db.get_value("Guardian", guardian.guardian, "email_address")
|
where g.name = sg.guardian and sg.parent = %s and sg.parenttype = 'Student'
|
||||||
if email:
|
""", self.student)
|
||||||
email_list.append(email)
|
|
||||||
return ", ".join(email_list)
|
student_emails.append(frappe.db.get_value("Student", self.student, "student_email_id"))
|
||||||
|
return ", ".join(list(set(student_emails)))
|
||||||
|
|
||||||
|
|
||||||
def calculate_total(self):
|
def calculate_total(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user