mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-25 16:04:46 +00:00
Bank Reconciliation Statement: Show balance in debit or credit column based on account type
This commit is contained in:
@@ -8,6 +8,7 @@ wn.query_reports["Bank Reconciliation Statement"] = {
|
|||||||
"label": wn._("Bank Account"),
|
"label": wn._("Bank Account"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Account",
|
"options": "Account",
|
||||||
|
"reqd": 1,
|
||||||
"get_query": function() {
|
"get_query": function() {
|
||||||
return {
|
return {
|
||||||
"query": "accounts.utils.get_account_list",
|
"query": "accounts.utils.get_account_list",
|
||||||
@@ -22,7 +23,8 @@ wn.query_reports["Bank Reconciliation Statement"] = {
|
|||||||
"fieldname":"report_date",
|
"fieldname":"report_date",
|
||||||
"label": wn._("Date"),
|
"label": wn._("Date"),
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"default": get_today()
|
"default": get_today(),
|
||||||
|
"reqd": 1
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -3,13 +3,14 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import webnotes
|
||||||
from webnotes import _, msgprint
|
|
||||||
from webnotes.utils import flt
|
from webnotes.utils import flt
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
if not filters: filters = {}
|
if not filters: filters = {}
|
||||||
|
|
||||||
columns = get_columns()
|
debit_or_credit = webnotes.conn.get_value("Account", filters["account"], "debit_or_credit")
|
||||||
|
|
||||||
|
columns = get_columns()
|
||||||
data = get_entries(filters)
|
data = get_entries(filters)
|
||||||
|
|
||||||
from accounts.utils import get_balance_on
|
from accounts.utils import get_balance_on
|
||||||
@@ -20,47 +21,39 @@ def execute(filters=None):
|
|||||||
total_debit += flt(d[4])
|
total_debit += flt(d[4])
|
||||||
total_credit += flt(d[5])
|
total_credit += flt(d[5])
|
||||||
|
|
||||||
if webnotes.conn.get_value("Account", filters["account"], "debit_or_credit") == 'Debit':
|
if debit_or_credit == 'Debit':
|
||||||
bank_bal = flt(balance_as_per_company) - flt(total_debit) + flt(total_credit)
|
bank_bal = flt(balance_as_per_company) - flt(total_debit) + flt(total_credit)
|
||||||
else:
|
else:
|
||||||
bank_bal = flt(balance_as_per_company) + flt(total_debit) - flt(total_credit)
|
bank_bal = flt(balance_as_per_company) + flt(total_debit) - flt(total_credit)
|
||||||
|
|
||||||
data += [
|
data += [
|
||||||
["", "", "", "Balance as per company books", balance_as_per_company, ""],
|
get_balance_row("Balance as per company books", balance_as_per_company, debit_or_credit),
|
||||||
["", "", "", "Amounts not reflected in bank", total_debit, total_credit],
|
["", "", "", "Amounts not reflected in bank", total_debit, total_credit],
|
||||||
["", "", "", "Balance as per bank", bank_bal, ""]
|
get_balance_row("Balance as per bank", bank_bal, debit_or_credit)
|
||||||
]
|
]
|
||||||
|
|
||||||
return columns, data
|
|
||||||
|
|
||||||
|
return columns, data
|
||||||
|
|
||||||
def get_columns():
|
def get_columns():
|
||||||
return ["Journal Voucher:Link/Journal Voucher:140", "Posting Date:Date:100",
|
return ["Journal Voucher:Link/Journal Voucher:140", "Posting Date:Date:100",
|
||||||
"Clearance Date:Date:110", "Against Account:Link/Account:200",
|
"Clearance Date:Date:110", "Against Account:Link/Account:200",
|
||||||
"Debit:Currency:120", "Credit:Currency:120"
|
"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):
|
def get_entries(filters):
|
||||||
conditions = get_conditions(filters)
|
entries = webnotes.conn.sql("""select
|
||||||
entries = webnotes.conn.sql("""select jv.name, jv.posting_date, jv.clearance_date,
|
jv.name, jv.posting_date, jv.clearance_date, jvd.against_account, jvd.debit, jvd.credit
|
||||||
jvd.against_account, jvd.debit, jvd.credit
|
from
|
||||||
from `tabJournal Voucher Detail` jvd, `tabJournal Voucher` jv
|
`tabJournal Voucher Detail` jvd, `tabJournal Voucher` jv
|
||||||
where jvd.parent = jv.name and jv.docstatus=1 and ifnull(jv.cheque_no, '')!= '' %s
|
where jvd.parent = jv.name and jv.docstatus=1 and ifnull(jv.cheque_no, '')!= ''
|
||||||
order by jv.name DESC""" % conditions, filters, as_list=1)
|
and jvd.account = %(account)s and jv.posting_date <= %(report_date)s
|
||||||
|
and ifnull(jv.clearance_date, '4000-01-01') > %(report_date)s
|
||||||
|
order by jv.name DESC""", filters, as_list=1)
|
||||||
|
|
||||||
return entries
|
return entries
|
||||||
|
|
||||||
|
def get_balance_row(label, amount, debit_or_credit):
|
||||||
|
if debit_or_credit == "Debit":
|
||||||
|
return ["", "", "", label, amount, 0]
|
||||||
|
else:
|
||||||
|
return ["", "", "", label, 0, amount]
|
||||||
Reference in New Issue
Block a user