make payment request for the fee

This commit is contained in:
Manas Solanki 2017-07-17 11:26:42 +05:30 committed by Nabin Hait
parent f073814635
commit e4acf763a5
11 changed files with 863 additions and 201 deletions

View File

@ -61,6 +61,7 @@ class PaymentRequest(Document):
def set_payment_request_url(self):
if self.payment_account:
self.payment_url = self.get_payment_url()
print (self.payment_url)
if self.payment_url:
self.db_set('payment_url', self.payment_url)
@ -69,8 +70,11 @@ class PaymentRequest(Document):
self.db_set('status', 'Initiated')
def get_payment_url(self):
data = frappe.db.get_value(self.reference_doctype, self.reference_name,
["company", "customer_name"], as_dict=1)
if self.reference_doctype != "Fees":
data = frappe.db.get_value(self.reference_doctype, self.reference_name, ["company", "customer_name"], as_dict=1)
else:
data = frappe.db.get_value(self.reference_doctype, self.reference_name, ["student_name"], as_dict=1)
data.update({"company": frappe.defaults.get_defaults().company})
controller = get_payment_gateway_controller(self.payment_gateway)
controller.validate_transaction_currency(self.currency)
@ -98,6 +102,7 @@ class PaymentRequest(Document):
def create_payment_entry(self, submit=True):
"""create entry"""
print ("creating the payment entry")
frappe.flags.ignore_account_permission = True
ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name)
@ -252,6 +257,7 @@ def make_payment_request(**args):
if args.order_type == "Shopping Cart" or args.mute_email:
pr.flags.mute_email = True
print ("comign in creatinf the new dottype")
if args.submit_doc:
pr.insert(ignore_permissions=True)
pr.submit()
@ -277,6 +283,9 @@ def get_amount(ref_doc, dt):
else:
grand_total = flt(ref_doc.outstanding_amount) / ref_doc.conversion_rate
if dt == "Fees":
grand_total = ref_doc.outstanding_amount
if grand_total > 0 :
return grand_total

View File

@ -583,8 +583,11 @@ class SalesInvoice(SellingController):
return
if not gl_entries:
print ("if not gl_entries")
gl_entries = self.get_gl_entries()
print (gl_entries)
if gl_entries:
from erpnext.accounts.general_ledger import make_gl_entries
@ -593,6 +596,7 @@ class SalesInvoice(SellingController):
make_gl_entries(gl_entries, cancel=(self.docstatus == 2),
update_outstanding=update_outstanding, merge_entries=False)
# frappe.throw("go ahead bro")
if update_outstanding == "No":
from erpnext.accounts.doctype.gl_entry.gl_entry import update_outstanding_amt
@ -609,18 +613,22 @@ class SalesInvoice(SellingController):
delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name)
def get_gl_entries(self, warehouse_account=None):
print ("inside the get_gl_entries")
from erpnext.accounts.general_ledger import merge_similar_entries
gl_entries = []
self.make_customer_gl_entry(gl_entries)
print ("make cuustomer gl entry", gl_entries)
self.make_tax_gl_entries(gl_entries)
self.make_item_gl_entries(gl_entries)
print ("make item gl entry", gl_entries)
# merge gl entries before adding pos entries
gl_entries = merge_similar_entries(gl_entries)
print ("after merged gl entry", gl_entries)
self.make_pos_gl_entries(gl_entries)
self.make_gle_for_change_amount(gl_entries)

View File

@ -107,6 +107,36 @@
"set_only_once": 0,
"unique": 0,
"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,
@ -120,7 +150,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2017-06-30 08:21:47.947269",
"modified": "2017-07-18 15:03:18.945746",
"modified_by": "Administrator",
"module": "Schools",
"name": "Fee Component",

View File

@ -3,14 +3,7 @@
frappe.ui.form.on('Fee Request', {
refresh: function(frm) {
},
fee_request_against: function(frm) {
if (frm.doc.fee_request_against == "Program") {
frm.set_value('student_groups', null)
} else if (frm.doc.fee_request_against == "Student Group") {
frm.set_value('programs', null)
}
frm.disable_save();
},
fee_structure: function(frm) {
if (frm.doc.fee_structure) {

View File

@ -5,7 +5,7 @@
"allow_rename": 0,
"autoname": "naming_series:",
"beta": 0,
"creation": "2015-09-22 16:57:22.143710",
"creation": "2017-07-18 15:21:21.527136",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
@ -411,36 +411,6 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "amended_from",
"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",
"length": 0,
"no_copy": 1,
"options": "Fee Request",
"permlevel": 0,
"print_hide": 1,
"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,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
@ -564,16 +534,15 @@
],
"has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"hide_toolbar": 1,
"idx": 0,
"image_view": 0,
"in_create": 0,
"is_submittable": 1,
"issingle": 0,
"is_submittable": 0,
"issingle": 1,
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
"modified": "2017-07-13 18:19:26.612801",
"modified": "2017-07-18 15:28:11.201755",
"modified_by": "Administrator",
"module": "Schools",
"name": "Fee Request",
@ -583,21 +552,21 @@
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 1,
"cancel": 0,
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"export": 0,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"report": 0,
"role": "Academics User",
"set_user_permissions": 0,
"share": 1,
"submit": 1,
"submit": 0,
"write": 1
}
],

View File

@ -49,10 +49,6 @@ class FeeRequest(Document):
self.grand_total = total_fee_count*self.total_amount
self.grand_total_in_words = money_in_words(self.grand_total)
if self.fee_request_against == "Student Group":
for student_group in self.student_groups:
students += get_student_group_students(student_group, self.academic_year)
@frappe.whitelist()
def get_fee_structure(source_name,target_doc=None):

View File

@ -13,6 +13,37 @@
"editable_grid": 0,
"engine": "InnoDB",
"fields": [
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "naming_series",
"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": "Naming Series",
"length": 0,
"no_copy": 0,
"options": "FS.",
"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": 1,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
@ -41,7 +72,7 @@
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"unique": 0
@ -77,37 +108,6 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "naming_series",
"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": "Naming Series",
"length": 0,
"no_copy": 0,
"options": "FS.",
"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": 1,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
@ -202,6 +202,37 @@
"set_only_once": 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_on_submit": 0,
@ -291,6 +322,35 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_11",
"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,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
@ -334,7 +394,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
"modified": "2017-07-13 15:20:45.727524",
"modified": "2017-07-18 15:02:29.909472",
"modified_by": "Administrator",
"module": "Schools",
"name": "Fee Structure",

View File

@ -2,9 +2,8 @@
cur_frm.add_fetch("student", "title", "student_name");
frappe.ui.form.on("Fees", {
onload: function(frm){
cur_frm.set_query("academic_term",function(){
frm.set_query("academic_term",function(){
return{
"filters":{
"academic_year": (frm.doc.academic_year)
@ -12,35 +11,102 @@ frappe.ui.form.on("Fees", {
};
});
cur_frm.set_query("fee_structure",function(){
frm.set_query("fee_structure",function(){
return{
"filters":{
"academic_term": (frm.doc.academic_term)
}
};
});
// debit account for booking the fee
frm.set_query("debit_to", function(doc) {
return {
filters: {
'account_type': 'Receivable',
'is_group': 0,
'company': doc.company
}
}
});
if (!frm.doc.posting_date) {
frm.doc.posting_date = frappe.datetime.get_today()
}
},
refresh: function(frm) {
if (frm.doc.docstatus === 1 && (frm.doc.total_amount > frm.doc.paid_amount)) {
frm.add_custom_button(__("Collect Fees"), function() {
frappe.prompt({fieldtype:"Float", label: __("Amount Paid"), fieldname:"amt"},
function(data) {
frappe.call({
method:"erpnext.schools.api.collect_fees",
args: {
"fees": frm.doc.name,
"amt": data.amt
},
callback: function(r) {
frm.doc.paid_amount = r.message
frm.doc.outstanding_amount = frm.doc.total_amount - r.message
frm.refresh()
}
});
}, __("Enter Paid Amount"), __("Collect"));
});
if(frm.doc.docstatus == 0 && frm.doc.set_posting_time) {
frm.set_df_property('posting_date', 'read_only', 0);
frm.set_df_property('posting_time', 'read_only', 0);
} else {
frm.set_df_property('posting_date', 'read_only', 1);
frm.set_df_property('posting_time', 'read_only', 1);
}
if(frm.doc.docstatus===1) {
frm.add_custom_button(__('Accounting Ledger'), function() {
frappe.route_options = {
voucher_no: frm.doc.name,
from_date: frm.doc.posting_date,
to_date: frm.doc.posting_date,
company: frm.doc.company,
group_by_voucher: false
};
frappe.set_route("query-report", "General Ledger");
}, __("View"));
}
if(frm.doc.docstatus===1 && frm.doc.outstanding_amount>0) {
frm.add_custom_button(__("Payment Request"), function() {
frm.events.make_payment_request(frm)
}, __("Make"));
frm.page.set_inner_btn_group_as_primary(__("Make"));
}
if(frm.doc.docstatus===1 && frm.doc.outstanding_amount!=0) {
frm.add_custom_button(__("Payment"), function() {
frm.events.make_payment_entry(frm)
}, __("Make"));
frm.page.set_inner_btn_group_as_primary(__("Make"));
}
},
// if (frm.doc.docstatus === 1 && (frm.doc.total_amount > frm.doc.paid_amount)) {
// frm.add_custom_button(__("Collect Fees"), function() {
// frappe.prompt({fieldtype:"Float", label: __("Amount Paid"), fieldname:"amt"},
// function(data) {
// frappe.call({
// method:"erpnext.schools.api.collect_fees",
// args: {
// "fees": frm.doc.name,
// "amt": data.amt
// },
// callback: function(r) {
// frm.doc.paid_amount = r.message
// frm.doc.outstanding_amount = frm.doc.total_amount - r.message
// frm.refresh()
// }
// });
// }, __("Enter Paid Amount"), __("Collect"));
// });
// }
make_payment_request: function(frm) {
frappe.call({
method:"erpnext.accounts.doctype.payment_request.payment_request.make_payment_request",
args: {
"dt": cur_frm.doc.doctype,
"dn": cur_frm.doc.name,
"recipient_id": cur_frm.doc.contact_email
},
callback: function(r) {
if(!r.exc){
var doc = frappe.model.sync(r.message);
frappe.set_route("Form", r.message.doctype, r.message.name);
}
}
})
},
set_posting_time: function(frm) {
frm.refresh()
},
program: function(frm) {
@ -88,14 +154,15 @@ frappe.ui.form.on("Fees", {
},
calculate_total_amount: function(frm) {
var total_amount = 0;
var grand_total = 0;
for(var i=0;i<frm.doc.components.length;i++) {
total_amount += frm.doc.components[i].amount;
grand_total += frm.doc.components[i].amount;
}
frm.set_value("total_amount", total_amount);
frm.set_value("grand_total", grand_total);
}
});
frappe.ui.form.on("Fee Component", {
amount: function(frm) {
frm.trigger("calculate_total_amount");

View File

@ -13,6 +13,37 @@
"editable_grid": 0,
"engine": "InnoDB",
"fields": [
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "naming_series",
"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": "Naming Series",
"length": 0,
"no_copy": 0,
"options": "FEE.",
"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": 1,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
@ -80,83 +111,22 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "student_category",
"fieldtype": "Link",
"hidden": 0,
"default": "",
"fieldname": "send_payment_request",
"fieldtype": "Check",
"hidden": 1,
"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": "Send Payment Request",
"length": 0,
"no_copy": 0,
"options": "Student Category",
"no_copy": 1,
"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_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "fee_structure",
"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": "Fee Structure",
"length": 0,
"no_copy": 0,
"options": "Fee Structure",
"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_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "due_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": "Due Date",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
@ -201,8 +171,8 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "naming_series",
"fieldtype": "Select",
"fieldname": "company",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
@ -210,10 +180,162 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Naming Series",
"label": "Institution",
"length": 0,
"no_copy": 0,
"options": "Company",
"permlevel": 0,
"precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 1,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 1,
"collapsible": 0,
"columns": 0,
"default": "Today",
"fieldname": "posting_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": "Date",
"length": 0,
"no_copy": 1,
"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": 1,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "posting_time",
"fieldtype": "Time",
"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": "Posting Time",
"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_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.docstatus==0",
"fieldname": "set_posting_time",
"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": "Edit Posting Date and Time",
"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_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "due_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": "Due Date",
"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": 1,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
"columns": 0,
"fieldname": "student_details",
"fieldtype": "Section 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,
"label": "Student Details",
"length": 0,
"no_copy": 0,
"options": "FEE.",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@ -223,7 +345,38 @@
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 1,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "program_enrollment",
"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": "Program Enrollment",
"length": 0,
"no_copy": 0,
"options": "Program Enrollment",
"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
},
{
@ -263,7 +416,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "program_enrollment",
"fieldname": "student_batch",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
@ -272,10 +425,101 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Program Enrollment",
"label": "Student Batch",
"length": 0,
"no_copy": 0,
"options": "Program Enrollment",
"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,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "contact_email",
"fieldtype": "Data",
"hidden": 1,
"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 Email",
"length": 0,
"no_copy": 0,
"options": "Email",
"permlevel": 0,
"precision": "",
"print_hide": 1,
"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,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_16",
"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,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "student_category",
"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",
"length": 0,
"no_copy": 0,
"options": "Student Category",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@ -379,6 +623,68 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "currency",
"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": "Currency",
"length": 0,
"no_copy": 0,
"options": "Currency",
"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_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "fee_structure",
"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": "Fee Structure",
"length": 0,
"no_copy": 0,
"options": "Fee Structure",
"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_on_submit": 0,
@ -505,7 +811,7 @@
"collapsible": 0,
"columns": 0,
"default": "0",
"fieldname": "total_amount",
"fieldname": "grand_total",
"fieldtype": "Currency",
"hidden": 0,
"ignore_user_permissions": 0,
@ -514,7 +820,7 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Total Amount",
"label": "Grand Total",
"length": 0,
"no_copy": 0,
"permlevel": 0,
@ -535,7 +841,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "total_amount_in_words",
"fieldname": "grand_total_in_words",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
@ -551,7 +857,7 @@
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
@ -620,6 +926,188 @@
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
"columns": 0,
"fieldname": "edit_printing_settings",
"fieldtype": "Section 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,
"label": "Printing Settings",
"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_on_submit": 1,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "letter_head",
"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": "Letter Head",
"length": 0,
"no_copy": 0,
"options": "Letter Head",
"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_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_32",
"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,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "select_print_heading",
"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": "Print Heading",
"length": 0,
"no_copy": 1,
"options": "Print Heading",
"permlevel": 0,
"precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 1,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "account",
"fieldtype": "Section 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,
"label": "Account",
"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_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "debit_to",
"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": "Debit To",
"length": 0,
"no_copy": 0,
"options": "Account",
"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,
"unique": 0
}
],
"has_web_view": 0,
@ -633,7 +1121,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
"modified": "2017-07-13 21:51:06.570598",
"modified": "2017-07-18 17:56:39.456516",
"modified_by": "Administrator",
"module": "Schools",
"name": "Fees",

View File

@ -7,18 +7,60 @@ from frappe.model.document import Document
import frappe
from frappe import _
from frappe.utils import money_in_words
from erpnext.accounts.doctype.payment_request.payment_request import make_payment_request
from frappe.utils.csvutils import getlink
class Fees(Document):
def validate(self):
self.set_missing_values()
self.calculate_total()
# self.validate_debit_to_account()
def set_missing_values(self):
if not self.contact_email:
self.contact_email = "manas@erpnext.com"
def calculate_total(self):
"""Calculates total amount."""
self.total_amount = 0
self.grand_total = 0
for d in self.components:
self.total_amount += d.amount
self.outstanding_amount = self.total_amount
self.total_amount_in_words = money_in_words(self.total_amount)
self.grand_total += d.amount
self.outstanding_amount = self.grand_total
self.grand_total_in_words = money_in_words(self.grand_total)
def on_submit(self):
self.make_gl_entries()
if self.send_payment_request:
pr = make_payment_request(dt="Fees", dn=self.name, recipient_id=self.contact_email,
submit_doc=True, use_dummy_message=True)
frappe.msgprint(_("Payment request {0} created").format(getlink("Payment Request", pr.name)))
def make_gl_entries(self, gl_entries=None, repost_future_gle=True, from_repost=False):
if not self.grand_total:
return
if not gl_entries:
gl_entries = self.get_gl_dict({
"account": self.debit_to,
"party_type": "Student",
"party": self.student,
"against": self.against_income_account,
"debit": grand_total_in_company_currency,
"debit_in_account_currency": grand_total_in_company_currency \
if self.party_account_currency==self.company_currency else self.grand_total,
"against_voucher": self.name,
"against_voucher_type": self.doctype
}, self.party_account_currency)
if gl_entries:
from erpnext.accounts.general_ledger import make_gl_entries
make_gl_entries(gl_entries, cancel=(self.docstatus == 2))
def get_fee_list(doctype, txt, filters, limit_start, limit_page_length=20, order_by="modified"):
user = frappe.session.user
@ -37,4 +79,4 @@ def get_list_context(context=None):
"title": _("Fees"),
"get_list": get_fee_list,
"row_template": "templates/includes/fee/fee_row.html"
}
}

View File

@ -1,11 +1,11 @@
frappe.listview_settings['Fees'] = {
add_fields: [ "total_amount", "paid_amount", "due_date"],
add_fields: [ "grand_total", "paid_amount", "due_date"],
get_indicator: function(doc) {
var { get_today } = frappe.datetime;
if ((doc.total_amount > doc.paid_amount) && doc.due_date < get_today()) {
if ((doc.grand_total > doc.paid_amount) && doc.due_date < get_today()) {
return [__("Overdue"), "red", ["due_date,<," + get_today()], ["due_date,<," + get_today()]];
}
else if (doc.total_amount > doc.paid_amount) {
else if (doc.grand_total > doc.paid_amount) {
return [__("Pending"), "orange"];
}
else {