diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index 017771a3a0..bf906cec07 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -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") diff --git a/erpnext/accounts/report/asset_depreciation_ledger/asset_depreciation_ledger.py b/erpnext/accounts/report/asset_depreciation_ledger/asset_depreciation_ledger.py index 318c590293..fb59882a8d 100644 --- a/erpnext/accounts/report/asset_depreciation_ledger/asset_depreciation_ledger.py +++ b/erpnext/accounts/report/asset_depreciation_ledger/asset_depreciation_ledger.py @@ -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 diff --git a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.js b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.js index 63f263f56d..91a06f4a40 100644 --- a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.js +++ b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.js @@ -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"), diff --git a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py index 750120b997..39f47710c3 100644 --- a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py +++ b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py @@ -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): diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py index f7bde6c054..41abc3f04b 100644 --- a/erpnext/accounts/report/financial_statements.py +++ b/erpnext/accounts/report/financial_statements.py @@ -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 "" diff --git a/erpnext/accounts/report/general_ledger/general_ledger.py b/erpnext/accounts/report/general_ledger/general_ledger.py index bd4dfb282d..6aecab904d 100644 --- a/erpnext/accounts/report/general_ledger/general_ledger.py +++ b/erpnext/accounts/report/general_ledger/general_ledger.py @@ -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") diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js index 1a73ae5c4f..9289d69f6e 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js @@ -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");