Skip to content

Commit

Permalink
fix: Ignore account closing balance for financial statement
Browse files Browse the repository at this point in the history
(cherry picked from commit ccf1920)

# Conflicts:
#	erpnext/accounts/doctype/accounts_settings/accounts_settings.json
  • Loading branch information
deepeshgarg007 authored and mergify[bot] committed Jul 27, 2023
1 parent dc603c3 commit 800417e
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 20 deletions.
12 changes: 12 additions & 0 deletions erpnext/accounts/doctype/accounts_settings/accounts_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"closing_settings_tab",
"period_closing_settings_section",
"acc_frozen_upto",
"ignore_account_closing_balance",
"column_break_25",
"frozen_accounts_modifier",
"report_settings_sb",
Expand Down Expand Up @@ -408,14 +409,25 @@
"fieldname": "enable_fuzzy_matching",
"fieldtype": "Check",
"label": "Enable Fuzzy Matching"
},
{
"default": "0",
"description": "Financial reports will be generated using GL Entry doctypes (should be enabled if Period Closing Voucher is not posted for all years sequentially or missing) ",
"fieldname": "ignore_account_closing_balance",
"fieldtype": "Check",
"label": "Ignore Account Closing Balance"
}
],
"icon": "icon-cog",
"idx": 1,
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
<<<<<<< HEAD
"modified": "2023-06-15 18:47:46.430291",
=======
"modified": "2023-07-27 15:05:34.000264",
>>>>>>> ccf1920a78 (fix: Ignore account closing balance for financial statement)
"modified_by": "Administrator",
"module": "Accounts",
"name": "Accounts Settings",
Expand Down
33 changes: 22 additions & 11 deletions erpnext/accounts/doctype/accounts_settings/accounts_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,32 @@


class AccountsSettings(Document):
def on_update(self):
frappe.clear_cache()

def validate(self):
frappe.db.set_default(
"add_taxes_from_item_tax_template", self.get("add_taxes_from_item_tax_template", 0)
)
old_doc = self.get_doc_before_save()
clear_cache = False

if old_doc.add_taxes_from_item_tax_template != self.add_taxes_from_item_tax_template:
frappe.db.set_default(
"add_taxes_from_item_tax_template", self.get("add_taxes_from_item_tax_template", 0)
)
clear_cache = True

frappe.db.set_default(
"enable_common_party_accounting", self.get("enable_common_party_accounting", 0)
)
if old_doc.enable_common_party_accounting != self.enable_common_party_accounting:
frappe.db.set_default(
"enable_common_party_accounting", self.get("enable_common_party_accounting", 0)
)
clear_cache = True

self.validate_stale_days()
self.enable_payment_schedule_in_print()
self.validate_pending_reposts()

if old_doc.show_payment_schedule_in_print != self.show_payment_schedule_in_print:
self.enable_payment_schedule_in_print()

if old_doc.acc_frozen_upto != self.acc_frozen_upto:
self.validate_pending_reposts()

if clear_cache:
frappe.clear_cache()

def validate_stale_days(self):
if not self.allow_stale and cint(self.stale_days) <= 0:
Expand Down
12 changes: 9 additions & 3 deletions erpnext/accounts/report/financial_statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,11 +429,17 @@ def set_gl_entries_by_account(

if accounts_list:
# For balance sheet
if not from_date:
from_date = filters["period_start_date"]
ignore_closing_balances = frappe.db.get_single_value(
"Accounts Settings", "ignore_account_closing_balance"
)
if not from_date and not ignore_closing_balances:
last_period_closing_voucher = frappe.db.get_all(
"Period Closing Voucher",
filters={"docstatus": 1, "company": filters.company, "posting_date": ("<", from_date)},
filters={
"docstatus": 1,
"company": filters.company,
"posting_date": ("<", filters["period_start_date"]),
},
fields=["posting_date", "name"],
order_by="posting_date desc",
limit=1,
Expand Down
18 changes: 12 additions & 6 deletions erpnext/accounts/report/trial_balance/trial_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,20 @@ def get_opening_balances(filters):
def get_rootwise_opening_balances(filters, report_type):
gle = []

last_period_closing_voucher = frappe.db.get_all(
"Period Closing Voucher",
filters={"docstatus": 1, "company": filters.company, "posting_date": ("<", filters.from_date)},
fields=["posting_date", "name"],
order_by="posting_date desc",
limit=1,
last_period_closing_voucher = ""
ignore_closing_balances = frappe.db.get_single_value(
"Accounts Settings", "ignore_account_closing_balance"
)

if not ignore_closing_balances:
last_period_closing_voucher = frappe.db.get_all(
"Period Closing Voucher",
filters={"docstatus": 1, "company": filters.company, "posting_date": ("<", filters.from_date)},
fields=["posting_date", "name"],
order_by="posting_date desc",
limit=1,
)

accounting_dimensions = get_accounting_dimensions(as_list=False)

if last_period_closing_voucher:
Expand Down

0 comments on commit 800417e

Please sign in to comment.