Changed condition of finance book in reports
This commit is contained in:
parent
7d6cad2c67
commit
f61e94e162
@ -332,12 +332,14 @@ class ReceivablePayableReport(object):
|
||||
conditions.append("company=%s")
|
||||
values.append(self.filters.company)
|
||||
|
||||
if self.filters.finance_book:
|
||||
company_finance_book = erpnext.get_default_finance_book(self.filters.company)
|
||||
|
||||
if not self.filters.finance_book or (self.filters.finance_book == company_finance_book):
|
||||
conditions.append("ifnull(finance_book,'') in (%s, '')")
|
||||
values.append(company_finance_book)
|
||||
elif self.filters.finance_book:
|
||||
conditions.append("ifnull(finance_book,'') = %s")
|
||||
values.append(self.filters.finance_book)
|
||||
else:
|
||||
conditions.append("ifnull(finance_book,'') in (%s, '')")
|
||||
values.append(erpnext.get_default_finance_book(self.filters.company))
|
||||
|
||||
if self.filters.get(party_type_field):
|
||||
conditions.append("party=%s")
|
||||
|
@ -42,11 +42,13 @@ def get_filter_conditions(filters):
|
||||
if filters.get("asset_category"):
|
||||
conditions += " and a.asset_category = %(asset_category)s"
|
||||
|
||||
if filters.get("finance_book"):
|
||||
conditions += " and ifnull(ds.finance_book, '') in (%(finance_book)s, '') "
|
||||
else:
|
||||
filters['finance_book'] = erpnext.get_default_finance_book(filters.get("company"))
|
||||
company_finance_book = erpnext.get_default_finance_book(filters.get("company"))
|
||||
|
||||
if (not filters.get('finance_book') or (filters.get('finance_book') == company_finance_book)):
|
||||
filters['finance_book'] = company_finance_book
|
||||
conditions += " and ifnull(ds.finance_book, '') in (%(finance_book)s, '') "
|
||||
elif filters.get("finance_book"):
|
||||
conditions += " and ifnull(ds.finance_book, '') = %(finance_book)s"
|
||||
|
||||
return conditions
|
||||
|
||||
|
@ -28,6 +28,12 @@ frappe.query_reports["Consolidated Financial Statement"] = {
|
||||
"default": frappe.defaults.get_user_default("fiscal_year"),
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname":"finance_book",
|
||||
"label": __("Finance Book"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Finance Book"
|
||||
},
|
||||
{
|
||||
"fieldname":"report",
|
||||
"label": __("Report"),
|
||||
|
@ -2,7 +2,7 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
import frappe, erpnext
|
||||
from frappe import _
|
||||
from frappe.utils import flt, cint
|
||||
from erpnext.accounts.report.financial_statements import get_fiscal_year_data, sort_accounts
|
||||
@ -322,7 +322,7 @@ def set_gl_entries_by_account(from_date, to_date, root_lft, root_rgt, filters, g
|
||||
company_lft, company_rgt = frappe.db.get_value('Company',
|
||||
filters.get('company'), ["lft", "rgt"])
|
||||
|
||||
additional_conditions = get_additional_conditions(from_date, ignore_closing_entries)
|
||||
additional_conditions = get_additional_conditions(from_date, ignore_closing_entries, filters)
|
||||
|
||||
gl_entries = frappe.db.sql("""select gl.posting_date, gl.account, gl.debit, gl.credit, gl.is_opening, gl.company,
|
||||
gl.fiscal_year, gl.debit_in_account_currency, gl.credit_in_account_currency, gl.account_currency,
|
||||
@ -353,7 +353,7 @@ def validate_entries(key, entry, accounts_by_name):
|
||||
field = "Account number" if entry.account_number else "Account name"
|
||||
frappe.throw(_("{0} {1} is not present in the parent company").format(field, key))
|
||||
|
||||
def get_additional_conditions(from_date, ignore_closing_entries):
|
||||
def get_additional_conditions(from_date, ignore_closing_entries, filters):
|
||||
additional_conditions = []
|
||||
|
||||
if ignore_closing_entries:
|
||||
@ -362,6 +362,15 @@ def get_additional_conditions(from_date, ignore_closing_entries):
|
||||
if from_date:
|
||||
additional_conditions.append("gl.posting_date >= %(from_date)s")
|
||||
|
||||
company_finance_book = erpnext.get_default_finance_book(filters.get("company"))
|
||||
|
||||
if not filters.get('finance_book') or (filters.get('finance_book') == company_finance_book):
|
||||
additional_conditions.append("finance_book in ('%s', '')" %
|
||||
frappe.db.escape(company_finance_book))
|
||||
elif filters.get("finance_book"):
|
||||
additional_conditions.append("finance_book = '%s' " %
|
||||
frappe.db.escape(filters.get("finance_book")))
|
||||
|
||||
return " and {}".format(" and ".join(additional_conditions)) if additional_conditions else ""
|
||||
|
||||
def add_total_row(out, root_type, balance_must_be, companies, company_currency):
|
||||
|
@ -375,13 +375,15 @@ def get_additional_conditions(from_date, ignore_closing_entries, filters):
|
||||
additional_conditions.append("project = '%s'" % (frappe.db.escape(filters.get("project"))))
|
||||
if filters.get("cost_center"):
|
||||
additional_conditions.append(get_cost_center_cond(filters.get("cost_center")))
|
||||
if filters.get("finance_book"):
|
||||
additional_conditions.append("finance_book in ('%s', '')" %
|
||||
frappe.db.escape(filters.get("finance_book")))
|
||||
else:
|
||||
additional_conditions.append("finance_book in ('%s', '')" %
|
||||
frappe.db.escape(erpnext.get_default_finance_book(filters.get("company"))))
|
||||
|
||||
company_finance_book = erpnext.get_default_finance_book(filters.get("company"))
|
||||
|
||||
if not filters.get('finance_book') or (filters.get('finance_book') == company_finance_book):
|
||||
additional_conditions.append("finance_book in ('%s', '')" %
|
||||
frappe.db.escape(company_finance_book))
|
||||
elif filters.get("finance_book"):
|
||||
additional_conditions.append("finance_book = '%s' " %
|
||||
frappe.db.escape(filters.get("finance_book")))
|
||||
|
||||
return " and {}".format(" and ".join(additional_conditions)) if additional_conditions else ""
|
||||
|
||||
|
@ -167,11 +167,12 @@ def get_conditions(filters):
|
||||
if filters.get("project"):
|
||||
conditions.append("project=%(project)s")
|
||||
|
||||
if filters.get("finance_book"):
|
||||
conditions.append("ifnull(finance_book, '') in (%(finance_book)s, '')")
|
||||
else:
|
||||
filters['finance_book'] = erpnext.get_default_finance_book(filters.get("company"))
|
||||
company_finance_book = erpnext.get_default_finance_book(filters.get("company"))
|
||||
if not filters.get("finance_book") or (filters.get("finance_book") == company_finance_book):
|
||||
filters['finance_book'] = company_finance_book
|
||||
conditions.append("ifnull(finance_book, '') in (%(finance_book)s, '')")
|
||||
elif filters.get("finance_book"):
|
||||
conditions.append("ifnull(finance_book, '') = %(finance_book)s")
|
||||
|
||||
from frappe.desk.reportview import build_match_conditions
|
||||
match_conditions = build_match_conditions("GL Entry")
|
||||
|
@ -35,6 +35,10 @@ frappe.ui.form.on("Purchase Receipt", {
|
||||
|
||||
},
|
||||
|
||||
onload_post_render: function(frm) {
|
||||
frm.get_field("items").grid.set_multiple_add("item_code", "qty");
|
||||
},
|
||||
|
||||
refresh: function(frm) {
|
||||
if(frm.doc.company) {
|
||||
frm.trigger("toggle_display_account_head");
|
||||
|
Loading…
Reference in New Issue
Block a user