Merge pull request #50824 from khushi8112/move-accounts-freezing-setting-to-company

refactor: Move accounts freezing setting to company
This commit is contained in:
Khushi Rawat
2025-12-04 12:16:46 +05:30
committed by GitHub
21 changed files with 167 additions and 100 deletions

View File

@@ -96,13 +96,28 @@ 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 not in frappe.get_roles()
and frappe.session.user != "Administrator"
):
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 +126,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)