From 2b39d5d6d50cd0ea823070dc6afb432d8acfc488 Mon Sep 17 00:00:00 2001 From: Manas Solanki Date: Mon, 24 Jul 2017 20:08:15 +0530 Subject: [PATCH] make gl_entry on submission of fees --- erpnext/accounts/doctype/gl_entry/gl_entry.py | 4 +- erpnext/accounts/general_ledger.py | 1 + .../doctype/fee_request/fee_request.json | 61 ++++++++- erpnext/schools/doctype/fees/fees.json | 127 +++++++++++++++++- erpnext/schools/doctype/fees/fees.py | 48 ++++--- 5 files changed, 214 insertions(+), 27 deletions(-) diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.py b/erpnext/accounts/doctype/gl_entry/gl_entry.py index 304af37308..47e214e1b4 100644 --- a/erpnext/accounts/doctype/gl_entry/gl_entry.py +++ b/erpnext/accounts/doctype/gl_entry/gl_entry.py @@ -36,7 +36,7 @@ class GLEntry(Document): validate_balance_type(self.account, adv_adj) # Update outstanding amt on against voucher - if self.against_voucher_type in ['Journal Entry', 'Sales Invoice', 'Purchase Invoice'] \ + if self.against_voucher_type in ['Journal Entry', 'Sales Invoice', 'Purchase Invoice', 'Fees'] \ and self.against_voucher and update_outstanding == 'Yes' and not from_repost: update_outstanding_amt(self.account, self.party_type, self.party, self.against_voucher_type, self.against_voucher) @@ -196,7 +196,7 @@ def update_outstanding_amt(account, party_type, party, against_voucher_type, aga frappe.throw(_("Outstanding for {0} cannot be less than zero ({1})").format(against_voucher, fmt_money(bal))) # Update outstanding amt on against voucher - if against_voucher_type in ["Sales Invoice", "Purchase Invoice"]: + if against_voucher_type in ["Sales Invoice", "Purchase Invoice", "Fees"]: ref_doc = frappe.get_doc(against_voucher_type, against_voucher) ref_doc.db_set('outstanding_amount', bal) ref_doc.set_status(update=True) diff --git a/erpnext/accounts/general_ledger.py b/erpnext/accounts/general_ledger.py index c575d59ae7..23715fa457 100644 --- a/erpnext/accounts/general_ledger.py +++ b/erpnext/accounts/general_ledger.py @@ -116,6 +116,7 @@ def round_off_debit_credit(gl_map): currency=frappe.db.get_value("Company", gl_map[0].company, "default_currency", cache=True)) debit_credit_diff = 0.0 + print ("gl map", gl_map) for entry in gl_map: entry.debit = flt(entry.debit, precision) entry.credit = flt(entry.credit, precision) diff --git a/erpnext/schools/doctype/fee_request/fee_request.json b/erpnext/schools/doctype/fee_request/fee_request.json index 3d7fa8f515..6cdcd8d506 100644 --- a/erpnext/schools/doctype/fee_request/fee_request.json +++ b/erpnext/schools/doctype/fee_request/fee_request.json @@ -13,6 +13,65 @@ "editable_grid": 0, "engine": "InnoDB", "fields": [ + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "create_fees", + "fieldtype": "Button", + "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": "Create Fees", + "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": "section_break_19", + "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, + "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, @@ -542,7 +601,7 @@ "issingle": 1, "istable": 0, "max_attachments": 0, - "modified": "2017-07-18 15:28:11.201755", + "modified": "2017-07-24 15:49:48.117287", "modified_by": "Administrator", "module": "Schools", "name": "Fee Request", diff --git a/erpnext/schools/doctype/fees/fees.json b/erpnext/schools/doctype/fees/fees.json index ab16f0099b..1a9dcc0c6a 100644 --- a/erpnext/schools/doctype/fees/fees.json +++ b/erpnext/schools/doctype/fees/fees.json @@ -4,7 +4,7 @@ "allow_import": 0, "allow_rename": 0, "autoname": "naming_series:", - "beta": 0, + "beta": 1, "creation": "2015-09-22 16:57:22.143710", "custom": 0, "docstatus": 0, @@ -114,7 +114,7 @@ "default": "", "fieldname": "send_payment_request", "fieldtype": "Check", - "hidden": 1, + "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, @@ -136,6 +136,36 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "include_payment", + "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": "Include Payment", + "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, @@ -1108,6 +1138,97 @@ "search_index": 0, "set_only_once": 0, "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "against_income_account", + "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": "Credit 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": 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_39", + "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": "cost_center", + "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": "Cost Center", + "length": 0, + "no_copy": 0, + "options": "Cost Center", + "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 } ], "has_web_view": 0, @@ -1121,7 +1242,7 @@ "istable": 0, "max_attachments": 0, "menu_index": 0, - "modified": "2017-07-18 17:56:39.456516", + "modified": "2017-07-24 20:01:58.683352", "modified_by": "Administrator", "module": "Schools", "name": "Fees", diff --git a/erpnext/schools/doctype/fees/fees.py b/erpnext/schools/doctype/fees/fees.py index 19cea7bf89..824a6647c2 100644 --- a/erpnext/schools/doctype/fees/fees.py +++ b/erpnext/schools/doctype/fees/fees.py @@ -9,9 +9,10 @@ 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 +from erpnext.controllers.accounts_controller import AccountsController -class Fees(Document): +class Fees(AccountsController): def validate(self): self.set_missing_values() self.calculate_total() @@ -20,6 +21,10 @@ class Fees(Document): def set_missing_values(self): if not self.contact_email: self.contact_email = "manas@erpnext.com" + if not self.against_income_account: + self.against_income_account = "Academic Fees - S" + if not self.cost_center: + self.cost_center = "Main - S" def calculate_total(self): """Calculates total amount.""" @@ -39,28 +44,29 @@ class Fees(Document): 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): + def make_gl_entries(self): 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)) - + student_gl_entries = self.get_gl_dict({ + "account": self.debit_to, + "party_type": "Student", + "party": self.student, + "against": self.against_income_account, + "debit": self.grand_total, + "debit_in_account_currency": self.grand_total, + "against_voucher": self.name, + "against_voucher_type": self.doctype + }) + fee_gl_entry = self.get_gl_dict({ + "account": self.against_income_account, + "against": self.student, + "credit": self.grand_total, + "credit_in_account_currency": self.grand_total, + "cost_center": self.cost_center + }) + from erpnext.accounts.general_ledger import make_gl_entries + make_gl_entries([student_gl_entries, fee_gl_entry], cancel=(self.docstatus == 2), + update_outstanding="Yes", merge_entries=False) def get_fee_list(doctype, txt, filters, limit_start, limit_page_length=20, order_by="modified"): user = frappe.session.user