fix: Ignore account closing balance for financial statement

This commit is contained in:
Deepesh Garg 2023-07-27 15:40:36 +05:30
parent 2c1943c7e6
commit ccf1920a78
4 changed files with 52 additions and 21 deletions

View File

@ -58,6 +58,7 @@
"closing_settings_tab", "closing_settings_tab",
"period_closing_settings_section", "period_closing_settings_section",
"acc_frozen_upto", "acc_frozen_upto",
"ignore_account_closing_balance",
"column_break_25", "column_break_25",
"frozen_accounts_modifier", "frozen_accounts_modifier",
"tab_break_dpet", "tab_break_dpet",
@ -406,6 +407,13 @@
"fieldname": "enable_fuzzy_matching", "fieldname": "enable_fuzzy_matching",
"fieldtype": "Check", "fieldtype": "Check",
"label": "Enable Fuzzy Matching" "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", "icon": "icon-cog",
@ -413,7 +421,7 @@
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"issingle": 1, "issingle": 1,
"links": [], "links": [],
"modified": "2023-06-15 16:35:45.123456", "modified": "2023-07-27 15:05:34.000264",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Accounts Settings", "name": "Accounts Settings",

View File

@ -14,21 +14,32 @@ from erpnext.stock.utils import check_pending_reposting
class AccountsSettings(Document): class AccountsSettings(Document):
def on_update(self):
frappe.clear_cache()
def validate(self): def validate(self):
frappe.db.set_default( old_doc = self.get_doc_before_save()
"add_taxes_from_item_tax_template", self.get("add_taxes_from_item_tax_template", 0) clear_cache = False
)
frappe.db.set_default( if old_doc.add_taxes_from_item_tax_template != self.add_taxes_from_item_tax_template:
"enable_common_party_accounting", self.get("enable_common_party_accounting", 0) frappe.db.set_default(
) "add_taxes_from_item_tax_template", self.get("add_taxes_from_item_tax_template", 0)
)
clear_cache = True
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.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): def validate_stale_days(self):
if not self.allow_stale and cint(self.stale_days) <= 0: if not self.allow_stale and cint(self.stale_days) <= 0:

View File

@ -429,11 +429,17 @@ def set_gl_entries_by_account(
if accounts_list: if accounts_list:
# For balance sheet # For balance sheet
if not from_date: ignore_closing_balances = frappe.db.get_single_value(
from_date = filters["period_start_date"] "Accounts Settings", "ignore_account_closing_balance"
)
if not from_date and not ignore_closing_balances:
last_period_closing_voucher = frappe.db.get_all( last_period_closing_voucher = frappe.db.get_all(
"Period Closing Voucher", "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"], fields=["posting_date", "name"],
order_by="posting_date desc", order_by="posting_date desc",
limit=1, limit=1,

View File

@ -142,14 +142,20 @@ def get_opening_balances(filters):
def get_rootwise_opening_balances(filters, report_type): def get_rootwise_opening_balances(filters, report_type):
gle = [] gle = []
last_period_closing_voucher = frappe.db.get_all( last_period_closing_voucher = ""
"Period Closing Voucher", ignore_closing_balances = frappe.db.get_single_value(
filters={"docstatus": 1, "company": filters.company, "posting_date": ("<", filters.from_date)}, "Accounts Settings", "ignore_account_closing_balance"
fields=["posting_date", "name"],
order_by="posting_date desc",
limit=1,
) )
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) accounting_dimensions = get_accounting_dimensions(as_list=False)
if last_period_closing_voucher: if last_period_closing_voucher: