fix: Account balance patch and query fixes (#36117)
This commit is contained in:
parent
b5f6a1cc20
commit
b4bd978791
@ -159,6 +159,8 @@ def get_rootwise_opening_balances(filters, report_type):
|
|||||||
accounting_dimensions,
|
accounting_dimensions,
|
||||||
period_closing_voucher=last_period_closing_voucher[0].name,
|
period_closing_voucher=last_period_closing_voucher[0].name,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Report getting generate from the mid of a fiscal year
|
||||||
if getdate(last_period_closing_voucher[0].posting_date) < getdate(
|
if getdate(last_period_closing_voucher[0].posting_date) < getdate(
|
||||||
add_days(filters.from_date, -1)
|
add_days(filters.from_date, -1)
|
||||||
):
|
):
|
||||||
@ -220,7 +222,10 @@ def get_opening_balance(
|
|||||||
if start_date:
|
if start_date:
|
||||||
opening_balance = opening_balance.where(closing_balance.posting_date >= start_date)
|
opening_balance = opening_balance.where(closing_balance.posting_date >= start_date)
|
||||||
opening_balance = opening_balance.where(closing_balance.is_opening == "No")
|
opening_balance = opening_balance.where(closing_balance.is_opening == "No")
|
||||||
opening_balance = opening_balance.where(closing_balance.posting_date < filters.from_date)
|
else:
|
||||||
|
opening_balance = opening_balance.where(
|
||||||
|
(closing_balance.posting_date < filters.from_date) | (closing_balance.is_opening == "Yes")
|
||||||
|
)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
not filters.show_unclosed_fy_pl_balances
|
not filters.show_unclosed_fy_pl_balances
|
||||||
|
|||||||
@ -317,7 +317,7 @@ erpnext.patches.v13_0.update_docs_link
|
|||||||
erpnext.patches.v15_0.update_asset_value_for_manual_depr_entries
|
erpnext.patches.v15_0.update_asset_value_for_manual_depr_entries
|
||||||
erpnext.patches.v15_0.update_gpa_and_ndb_for_assdeprsch
|
erpnext.patches.v15_0.update_gpa_and_ndb_for_assdeprsch
|
||||||
erpnext.patches.v14_0.create_accounting_dimensions_for_closing_balance
|
erpnext.patches.v14_0.create_accounting_dimensions_for_closing_balance
|
||||||
erpnext.patches.v14_0.update_closing_balances #17-05-2023
|
erpnext.patches.v14_0.update_closing_balances #14-07-2023
|
||||||
execute:frappe.db.set_single_value("Accounts Settings", "merge_similar_account_heads", 0)
|
execute:frappe.db.set_single_value("Accounts Settings", "merge_similar_account_heads", 0)
|
||||||
# below migration patches should always run last
|
# below migration patches should always run last
|
||||||
erpnext.patches.v14_0.migrate_gl_to_payment_ledger
|
erpnext.patches.v14_0.migrate_gl_to_payment_ledger
|
||||||
|
|||||||
@ -13,12 +13,13 @@ from erpnext.accounts.utils import get_fiscal_year
|
|||||||
def execute():
|
def execute():
|
||||||
frappe.db.truncate("Account Closing Balance")
|
frappe.db.truncate("Account Closing Balance")
|
||||||
|
|
||||||
|
for company in frappe.get_all("Company", pluck="name"):
|
||||||
i = 0
|
i = 0
|
||||||
company_wise_order = {}
|
company_wise_order = {}
|
||||||
for pcv in frappe.db.get_all(
|
for pcv in frappe.db.get_all(
|
||||||
"Period Closing Voucher",
|
"Period Closing Voucher",
|
||||||
fields=["company", "posting_date", "name"],
|
fields=["company", "posting_date", "name"],
|
||||||
filters={"docstatus": 1},
|
filters={"docstatus": 1, "company": company},
|
||||||
order_by="posting_date",
|
order_by="posting_date",
|
||||||
):
|
):
|
||||||
|
|
||||||
@ -38,6 +39,9 @@ def execute():
|
|||||||
entry["closing_date"] = pcv_doc.posting_date
|
entry["closing_date"] = pcv_doc.posting_date
|
||||||
entry["period_closing_voucher"] = pcv_doc.name
|
entry["period_closing_voucher"] = pcv_doc.name
|
||||||
|
|
||||||
|
closing_entries = []
|
||||||
|
|
||||||
|
if pcv.posting_date not in company_wise_order[pcv.company]:
|
||||||
# get all gl entries for the year
|
# get all gl entries for the year
|
||||||
closing_entries = frappe.db.get_all(
|
closing_entries = frappe.db.get_all(
|
||||||
"GL Entry",
|
"GL Entry",
|
||||||
@ -63,9 +67,8 @@ def execute():
|
|||||||
entry["period_closing_voucher"] = pcv_doc.name
|
entry["period_closing_voucher"] = pcv_doc.name
|
||||||
|
|
||||||
entries = gl_entries + closing_entries
|
entries = gl_entries + closing_entries
|
||||||
|
|
||||||
if entries:
|
if entries:
|
||||||
make_closing_entries(entries, voucher_name=pcv.name)
|
make_closing_entries(entries, voucher_name=pcv.name)
|
||||||
|
|
||||||
company_wise_order[pcv.company].append(pcv.posting_date)
|
|
||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
|
company_wise_order[pcv.company].append(pcv.posting_date)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user