From 76646fb279849deafe52ffc3451ac6d1945a6b08 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 1 May 2013 11:23:44 +0530 Subject: [PATCH] [script report] bank reconciliation statement in new style --- accounts/page/accounts_home/accounts_home.js | 5 ++ .../bank_reconciliation_statement/__init__.py | 0 .../bank_reconciliation_statement.js | 25 ++++++++ .../bank_reconciliation_statement.py | 63 +++++++++++++++++++ .../bank_reconciliation_statement.txt | 22 +++++++ 5 files changed, 115 insertions(+) create mode 100644 accounts/report/bank_reconciliation_statement/__init__.py create mode 100644 accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.js create mode 100644 accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py create mode 100644 accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.txt diff --git a/accounts/page/accounts_home/accounts_home.js b/accounts/page/accounts_home/accounts_home.js index 6a9f91a719..5779307f70 100644 --- a/accounts/page/accounts_home/accounts_home.js +++ b/accounts/page/accounts_home/accounts_home.js @@ -187,6 +187,11 @@ wn.module_page["Accounts"] = [ right: true, icon: "icon-list", items: [ + { + "label":wn._("Bank Reconciliation Statement"), + route: "query-report/Bank Reconciliation Statement", + doctype: "Journal Voucher" + }, { "label":wn._("Delivered Items To Be Billed"), route: "query-report/Delivered Items To Be Billed", diff --git a/accounts/report/bank_reconciliation_statement/__init__.py b/accounts/report/bank_reconciliation_statement/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.js b/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.js new file mode 100644 index 0000000000..28ac9205a6 --- /dev/null +++ b/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.js @@ -0,0 +1,25 @@ +wn.query_reports["Bank Reconciliation Statement"] = { + "filters": [ + { + "fieldname":"account", + "label": "Bank Account", + "fieldtype": "Link", + "options": "Account", + "get_query": function() { + return { + "query": "accounts.utils.get_account_list", + "filters": { + "is_pl_account": "No", + "account_type": "Bank or Cash" + } + } + } + }, + { + "fieldname":"report_date", + "label": "Date", + "fieldtype": "Date", + "default": get_today() + }, + ] +} \ No newline at end of file diff --git a/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py b/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py new file mode 100644 index 0000000000..4275958e5d --- /dev/null +++ b/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py @@ -0,0 +1,63 @@ +from __future__ import unicode_literals +import webnotes +from webnotes import _, msgprint +from webnotes.utils import flt + +def execute(filters=None): + if not filters: filters = {} + + columns = get_columns() + data = get_entries(filters) + + from accounts.utils import get_balance_on + balance_as_per_company = get_balance_on(filters["account"], filters["report_date"]) + + total_debit, total_credit = 0,0 + for d in data: + total_debit += flt(d[4]) + total_credit += flt(d[5]) + + if webnotes.conn.get_value("Account", filters["account"], "debit_or_credit") == 'Debit': + bank_bal = flt(balance_as_per_company) - flt(total_debit) + flt(total_credit) + else: + bank_bal = flt(balance_as_per_company) + flt(total_debit) - flt(total_credit) + + data += [ + ["", "", "", "Balance as per company books", balance_as_per_company, ""], + ["", "", "", "Amounts not reflected in bank", total_debit, total_credit], + ["", "", "", "Balance as per bank", bank_bal, ""] + ] + + return columns, data + + +def get_columns(): + return ["Journal Voucher:Link/Journal Voucher:140", "Posting Date:Date:100", + "Clearance Date:Date:110", "Against Account:Link/Account:200", + "Debit:Currency:120", "Credit:Currency:120" + ] + +def get_conditions(filters): + conditions = "" + if not filters.get("account"): + msgprint(_("Please select Bank Account"), raise_exception=1) + else: + conditions += " and jvd.account = %(account)s" + + if not filters.get("report_date"): + msgprint(_("Please select Date on which you want to run the report"), raise_exception=1) + else: + conditions += """ and jv.posting_date <= %(report_date)s + and ifnull(jv.clearance_date, '4000-01-01') > %(report_date)s""" + + return conditions + +def get_entries(filters): + conditions = get_conditions(filters) + entries = webnotes.conn.sql("""select jv.name, jv.posting_date, jv.clearance_date, + jvd.against_account, jvd.debit, jvd.credit + from `tabJournal Voucher Detail` jvd, `tabJournal Voucher` jv + where jvd.parent = jv.name and jv.docstatus=1 and ifnull(jv.cheque_no, '')!= '' %s + order by jv.name DESC""" % conditions, filters, as_list=1) + + return entries \ No newline at end of file diff --git a/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.txt b/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.txt new file mode 100644 index 0000000000..9867c5ded7 --- /dev/null +++ b/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.txt @@ -0,0 +1,22 @@ +[ + { + "creation": "2013-04-30 18:30:21", + "docstatus": 0, + "modified": "2013-05-01 10:53:12", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "add_total_row": 0, + "doctype": "Report", + "is_standard": "Yes", + "name": "__common__", + "ref_doctype": "Journal Voucher", + "report_name": "Bank Reconciliation Statement", + "report_type": "Script Report" + }, + { + "doctype": "Report", + "name": "Bank Reconciliation Statement" + } +] \ No newline at end of file