fix: account closing balance patch
This commit is contained in:
parent
e927f6cab1
commit
2b8c39eee9
@ -326,7 +326,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 #10-05-2023
|
erpnext.patches.v14_0.update_closing_balances #17-05-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,8 +13,8 @@ from erpnext.accounts.utils import get_fiscal_year
|
|||||||
def execute():
|
def execute():
|
||||||
frappe.db.truncate("Account Closing Balance")
|
frappe.db.truncate("Account Closing Balance")
|
||||||
|
|
||||||
|
i = 0
|
||||||
company_wise_order = {}
|
company_wise_order = {}
|
||||||
get_opening_entries = True
|
|
||||||
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"],
|
||||||
@ -29,6 +29,7 @@ def execute():
|
|||||||
pcv.posting_date, pcv.fiscal_year, company=pcv.company
|
pcv.posting_date, pcv.fiscal_year, company=pcv.company
|
||||||
)[1]
|
)[1]
|
||||||
|
|
||||||
|
# get gl entries against pcv
|
||||||
gl_entries = frappe.db.get_all(
|
gl_entries = frappe.db.get_all(
|
||||||
"GL Entry", filters={"voucher_no": pcv.name, "is_cancelled": 0}, fields=["*"]
|
"GL Entry", filters={"voucher_no": pcv.name, "is_cancelled": 0}, fields=["*"]
|
||||||
)
|
)
|
||||||
@ -37,20 +38,31 @@ 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
|
||||||
|
|
||||||
|
# get all gl entries for the year
|
||||||
closing_entries = frappe.db.get_all(
|
closing_entries = frappe.db.get_all(
|
||||||
"GL Entry",
|
"GL Entry",
|
||||||
filters={
|
filters={
|
||||||
"is_cancelled": 0,
|
"is_cancelled": 0,
|
||||||
"voucher_no": ["!=", pcv.name],
|
"voucher_no": ["!=", pcv.name],
|
||||||
"posting_date": ["<=", pcv.posting_date],
|
"posting_date": ["between", [pcv_doc.year_start_date, pcv.posting_date]],
|
||||||
|
"is_opening": "No",
|
||||||
},
|
},
|
||||||
fields=["*"],
|
fields=["*"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if i == 0:
|
||||||
|
# add opening entries only for the first pcv
|
||||||
|
closing_entries += frappe.db.get_all(
|
||||||
|
"GL Entry",
|
||||||
|
filters={"is_cancelled": 0, "is_opening": "Yes"},
|
||||||
|
fields=["*"],
|
||||||
|
)
|
||||||
|
|
||||||
for entry in closing_entries:
|
for entry in closing_entries:
|
||||||
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
|
||||||
|
|
||||||
make_closing_entries(gl_entries + closing_entries, voucher_name=pcv.name)
|
make_closing_entries(gl_entries + closing_entries, voucher_name=pcv.name)
|
||||||
company_wise_order[pcv.company].append(pcv.posting_date)
|
company_wise_order[pcv.company].append(pcv.posting_date)
|
||||||
get_opening_entries = False
|
|
||||||
|
i += 1
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user