chore: Minor fixes
This commit is contained in:
parent
e5f603c9d9
commit
c089c4156c
@ -142,16 +142,31 @@ def get_opening_balances(filters):
|
|||||||
|
|
||||||
def get_rootwise_opening_balances(filters, report_type):
|
def get_rootwise_opening_balances(filters, report_type):
|
||||||
gle = []
|
gle = []
|
||||||
accounting_dimensions = get_accounting_dimensions(as_list=False)
|
|
||||||
gle = get_opening_balance("Closing Balance", filters, report_type, accounting_dimensions)
|
|
||||||
|
|
||||||
last_period_closing_voucher_date = frappe.db.get_value(
|
last_period_closing_voucher = frappe.db.get_all(
|
||||||
"Period Closing Voucher", {"docstatus": 1, "company": filters.company}, "max(posting_date)"
|
"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,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check If need to get opening balance from GL Entry
|
accounting_dimensions = get_accounting_dimensions(as_list=False)
|
||||||
if getdate(last_period_closing_voucher_date) < getdate(add_days(filters.from_date, -1)):
|
|
||||||
filters.from_date = add_days(last_period_closing_voucher_date, 1)
|
if last_period_closing_voucher:
|
||||||
|
gle = get_opening_balance(
|
||||||
|
"Closing Balance",
|
||||||
|
filters,
|
||||||
|
report_type,
|
||||||
|
accounting_dimensions,
|
||||||
|
period_closing_voucher=last_period_closing_voucher[0].name,
|
||||||
|
)
|
||||||
|
if getdate(last_period_closing_voucher[0].posting_date) < getdate(
|
||||||
|
add_days(filters.from_date, -1)
|
||||||
|
):
|
||||||
|
filters.from_date = add_days(last_period_closing_voucher, 1)
|
||||||
|
gle = get_opening_balance("GL Entry", filters, report_type, accounting_dimensions)
|
||||||
|
else:
|
||||||
gle = get_opening_balance("GL Entry", filters, report_type, accounting_dimensions)
|
gle = get_opening_balance("GL Entry", filters, report_type, accounting_dimensions)
|
||||||
|
|
||||||
opening = frappe._dict()
|
opening = frappe._dict()
|
||||||
@ -161,7 +176,9 @@ def get_rootwise_opening_balances(filters, report_type):
|
|||||||
return opening
|
return opening
|
||||||
|
|
||||||
|
|
||||||
def get_opening_balance(doctype, filters, report_type, accounting_dimensions):
|
def get_opening_balance(
|
||||||
|
doctype, filters, report_type, accounting_dimensions, period_closing_voucher=None
|
||||||
|
):
|
||||||
closing_balance = frappe.qb.DocType(doctype)
|
closing_balance = frappe.qb.DocType(doctype)
|
||||||
account = frappe.qb.DocType("Account")
|
account = frappe.qb.DocType("Account")
|
||||||
|
|
||||||
@ -185,6 +202,10 @@ def get_opening_balance(doctype, filters, report_type, accounting_dimensions):
|
|||||||
|
|
||||||
if doctype == "Closing Balance":
|
if doctype == "Closing Balance":
|
||||||
opening_balance = opening_balance.where(closing_balance.closing_date < filters.from_date)
|
opening_balance = opening_balance.where(closing_balance.closing_date < filters.from_date)
|
||||||
|
if period_closing_voucher:
|
||||||
|
opening_balance = opening_balance.where(
|
||||||
|
closing_balance.period_closing_voucher == period_closing_voucher
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
opening_balance = opening_balance.where(closing_balance.posting_date < filters.from_date)
|
opening_balance = opening_balance.where(closing_balance.posting_date < filters.from_date)
|
||||||
|
|
||||||
|
|||||||
@ -328,4 +328,4 @@ erpnext.patches.v14_0.change_autoname_for_tax_withheld_vouchers
|
|||||||
erpnext.patches.v14_0.set_pick_list_status
|
erpnext.patches.v14_0.set_pick_list_status
|
||||||
erpnext.patches.v15_0.update_asset_value_for_manual_depr_entries
|
erpnext.patches.v15_0.update_asset_value_for_manual_depr_entries
|
||||||
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
|
erpnext.patches.v14_0.update_closing_balances #13
|
||||||
|
|||||||
@ -25,5 +25,5 @@ def execute():
|
|||||||
)[1]
|
)[1]
|
||||||
pcv_doc.make_closing_entries()
|
pcv_doc.make_closing_entries()
|
||||||
gl_entries = pcv_doc.get_gl_entries()
|
gl_entries = pcv_doc.get_gl_entries()
|
||||||
make_closing_entries(gl_entries, is_period_closing_voucher_entry=True)
|
make_closing_entries(gl_entries, is_period_closing_voucher_entry=True, voucher_name=pcv.name)
|
||||||
company_wise_order[pcv.company].append(pcv.posting_date)
|
company_wise_order[pcv.company].append(pcv.posting_date)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user