refactor: updated logic in depreciation and gl to validate acc frozen date company wise

This commit is contained in:
Khushi Rawat
2025-06-10 16:01:51 +05:30
committed by khushi8112
parent 58db596027
commit 17a6392407
2 changed files with 26 additions and 27 deletions

View File

@@ -96,13 +96,26 @@ def get_depreciable_assets_data(date):
.orderby(a.creation, order=Order.desc)
)
acc_frozen_upto = get_acc_frozen_upto()
if acc_frozen_upto:
res = res.where(ds.schedule_date > acc_frozen_upto)
companies_with_frozen_limits = get_companies_with_frozen_limits()
res = res.run()
for company, frozen_upto in companies_with_frozen_limits.items():
res = res.where((a.company != company) | (ds.schedule_date > frozen_upto))
return res
return res.run()
def get_companies_with_frozen_limits():
companies_with_frozen_limits = {}
for d in frappe.get_all(
"Company", fields=["name", "accounts_frozen_till_date", "role_allowed_for_frozen_entries"]
):
if not d.accounts_frozen_till_date:
continue
if d.role_allowed_for_frozen_entries in frappe.get_roles() or frappe.session.user == "Administrator":
continue
companies_with_frozen_limits[d.name] = getdate(d.accounts_frozen_till_date)
return companies_with_frozen_limits
def make_depreciation_entry_on_disposal(asset_doc, disposal_date=None):
@@ -111,20 +124,6 @@ def make_depreciation_entry_on_disposal(asset_doc, disposal_date=None):
make_depreciation_entry(depr_schedule_name, disposal_date)
def get_acc_frozen_upto():
acc_frozen_upto = frappe.get_single_value("Accounts Settings", "acc_frozen_upto")
if not acc_frozen_upto:
return
frozen_accounts_modifier = frappe.get_single_value("Accounts Settings", "frozen_accounts_modifier")
if frozen_accounts_modifier not in frappe.get_roles() or frappe.session.user == "Administrator":
return getdate(acc_frozen_upto)
return
def get_credit_debit_accounts_for_asset(asset_category, company):
# Returns credit and debit accounts for the given asset category and company.
(_, accumulated_depr_account, depr_expense_account) = get_depreciation_accounts(asset_category, company)