mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-12 11:25:09 +00:00
perf: Use cached accounts settings (#47947)
This commit is contained in:
@@ -317,7 +317,7 @@ def get_already_booked_amount(doc, item):
|
||||
def book_deferred_income_or_expense(doc, deferred_process, posting_date=None):
|
||||
enable_check = "enable_deferred_revenue" if doc.doctype == "Sales Invoice" else "enable_deferred_expense"
|
||||
|
||||
accounts_frozen_upto = frappe.db.get_single_value("Accounts Settings", "acc_frozen_upto")
|
||||
accounts_frozen_upto = frappe.get_settings("Accounts Settings", "acc_frozen_upto")
|
||||
|
||||
def _book_deferred_revenue_or_expense(
|
||||
item,
|
||||
|
||||
@@ -92,7 +92,7 @@ class Account(NestedSet):
|
||||
super().on_update()
|
||||
|
||||
def onload(self):
|
||||
frozen_accounts_modifier = frappe.db.get_single_value("Accounts Settings", "frozen_accounts_modifier")
|
||||
frozen_accounts_modifier = frappe.get_settings("Accounts Settings", "frozen_accounts_modifier")
|
||||
if not frozen_accounts_modifier or frozen_accounts_modifier in frappe.get_roles():
|
||||
self.set_onload("can_freeze_account", True)
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class AutoMatchParty:
|
||||
deposit=self.deposit,
|
||||
).match()
|
||||
|
||||
fuzzy_matching_enabled = frappe.db.get_single_value("Accounts Settings", "enable_fuzzy_matching")
|
||||
fuzzy_matching_enabled = frappe.get_settings("Accounts Settings", "enable_fuzzy_matching")
|
||||
if not result and fuzzy_matching_enabled:
|
||||
result = AutoMatchbyPartyNameDescription(
|
||||
bank_party_name=self.bank_party_name, description=self.description, deposit=self.deposit
|
||||
|
||||
@@ -121,7 +121,7 @@ class BankTransaction(Document):
|
||||
self.allocate_payment_entries()
|
||||
self.set_status()
|
||||
|
||||
if frappe.db.get_single_value("Accounts Settings", "enable_party_matching"):
|
||||
if frappe.get_settings("Accounts Settings", "enable_party_matching"):
|
||||
self.auto_set_party()
|
||||
|
||||
def before_update_after_submit(self):
|
||||
|
||||
@@ -1171,7 +1171,7 @@ class JournalEntry(AccountsController):
|
||||
def make_gl_entries(self, cancel=0, adv_adj=0):
|
||||
from erpnext.accounts.general_ledger import make_gl_entries
|
||||
|
||||
merge_entries = frappe.db.get_single_value("Accounts Settings", "merge_similar_account_heads")
|
||||
merge_entries = frappe.get_settings("Accounts Settings", "merge_similar_account_heads")
|
||||
|
||||
gl_map = self.build_gl_map()
|
||||
if self.voucher_type in ("Deferred Revenue", "Deferred Expense"):
|
||||
|
||||
@@ -2969,7 +2969,7 @@ def get_payment_entry(
|
||||
created_from_payment_request=False,
|
||||
):
|
||||
doc = frappe.get_doc(dt, dn)
|
||||
over_billing_allowance = frappe.db.get_single_value("Accounts Settings", "over_billing_allowance")
|
||||
over_billing_allowance = frappe.get_settings("Accounts Settings", "over_billing_allowance")
|
||||
if dt in ("Sales Order", "Purchase Order") and flt(doc.per_billed, 2) >= (100.0 + over_billing_allowance):
|
||||
frappe.throw(_("Can only make payment against unbilled {0}").format(_(dt)))
|
||||
|
||||
@@ -3109,7 +3109,7 @@ def get_payment_entry(
|
||||
if party_account and bank:
|
||||
if discount_amount:
|
||||
base_total_discount_loss = 0
|
||||
if frappe.db.get_single_value("Accounts Settings", "book_tax_discount_loss"):
|
||||
if frappe.get_settings("Accounts Settings", "book_tax_discount_loss"):
|
||||
base_total_discount_loss = split_early_payment_discount_loss(pe, doc, valid_discounts)
|
||||
|
||||
set_pending_discount_loss(
|
||||
@@ -3463,7 +3463,7 @@ def set_pending_discount_loss(pe, doc, discount_amount, base_total_discount_loss
|
||||
|
||||
# If tax loss booking is enabled, pending loss will be rounding loss.
|
||||
# Otherwise it will be the total discount loss.
|
||||
book_tax_loss = frappe.db.get_single_value("Accounts Settings", "book_tax_discount_loss")
|
||||
book_tax_loss = frappe.get_settings("Accounts Settings", "book_tax_discount_loss")
|
||||
account_type = "round_off_account" if book_tax_loss else "default_discount_account"
|
||||
|
||||
pe.append(
|
||||
|
||||
@@ -407,7 +407,7 @@ class PaymentReconciliation(Document):
|
||||
|
||||
@frappe.whitelist()
|
||||
def is_auto_process_enabled(self):
|
||||
return frappe.db.get_single_value("Accounts Settings", "auto_reconcile_payments")
|
||||
return frappe.get_settings("Accounts Settings", "auto_reconcile_payments")
|
||||
|
||||
@frappe.whitelist()
|
||||
def calculate_difference_on_allocation_change(self, payment_entry, invoice, allocated_amount):
|
||||
@@ -532,7 +532,7 @@ class PaymentReconciliation(Document):
|
||||
|
||||
@frappe.whitelist()
|
||||
def reconcile(self):
|
||||
if frappe.db.get_single_value("Accounts Settings", "auto_reconcile_payments"):
|
||||
if frappe.get_settings("Accounts Settings", "auto_reconcile_payments"):
|
||||
running_doc = is_any_doc_running(
|
||||
dict(
|
||||
company=self.company,
|
||||
|
||||
@@ -60,9 +60,7 @@ class POSClosingEntry(StatusUpdater):
|
||||
if frappe.db.get_value("POS Opening Entry", self.pos_opening_entry, "status") != "Open":
|
||||
frappe.throw(_("Selected POS Opening Entry should be open."), title=_("Invalid Opening Entry"))
|
||||
|
||||
self.is_pos_using_sales_invoice = frappe.db.get_single_value(
|
||||
"Accounts Settings", "use_sales_invoice_in_pos"
|
||||
)
|
||||
self.is_pos_using_sales_invoice = frappe.get_settings("Accounts Settings", "use_sales_invoice_in_pos")
|
||||
|
||||
if self.is_pos_using_sales_invoice == 0:
|
||||
self.validate_duplicate_pos_invoices()
|
||||
@@ -301,7 +299,7 @@ def make_closing_entry_from_opening(opening_entry):
|
||||
closing_entry.net_total = 0
|
||||
closing_entry.total_quantity = 0
|
||||
|
||||
is_pos_using_sales_invoice = frappe.db.get_single_value("Accounts Settings", "use_sales_invoice_in_pos")
|
||||
is_pos_using_sales_invoice = frappe.get_settings("Accounts Settings", "use_sales_invoice_in_pos")
|
||||
|
||||
pos_invoices = (
|
||||
get_pos_invoices(
|
||||
|
||||
@@ -424,9 +424,7 @@ class POSInvoice(SalesInvoice):
|
||||
)
|
||||
|
||||
def validate_is_pos_using_sales_invoice(self):
|
||||
self.is_pos_using_sales_invoice = frappe.db.get_single_value(
|
||||
"Accounts Settings", "use_sales_invoice_in_pos"
|
||||
)
|
||||
self.is_pos_using_sales_invoice = frappe.get_settings("Accounts Settings", "use_sales_invoice_in_pos")
|
||||
if self.is_pos_using_sales_invoice and not self.is_return:
|
||||
frappe.throw(_("Sales Invoice mode is activated in POS. Please create Sales Invoice instead."))
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ def trigger_job_for_doc(docname: str | None = None):
|
||||
if not docname:
|
||||
return
|
||||
|
||||
if not frappe.db.get_single_value("Accounts Settings", "auto_reconcile_payments"):
|
||||
if not frappe.get_settings("Accounts Settings", "auto_reconcile_payments"):
|
||||
frappe.throw(
|
||||
_("Auto Reconciliation of Payments has been disabled. Enable it through {0}").format(
|
||||
get_link_to_form("Accounts Settings", "Accounts Settings")
|
||||
@@ -190,7 +190,7 @@ def trigger_reconciliation_for_queued_docs():
|
||||
Will be called from Cron Job
|
||||
Fetch queued docs and start reconciliation process for each one
|
||||
"""
|
||||
if not frappe.db.get_single_value("Accounts Settings", "auto_reconcile_payments"):
|
||||
if not frappe.get_settings("Accounts Settings", "auto_reconcile_payments"):
|
||||
frappe.msgprint(
|
||||
_("Auto Reconciliation of Payments has been disabled. Enable it through {0}").format(
|
||||
get_link_to_form("Accounts Settings", "Accounts Settings")
|
||||
@@ -210,7 +210,7 @@ def trigger_reconciliation_for_queued_docs():
|
||||
|
||||
docs_to_trigger = []
|
||||
unique_filters = set()
|
||||
queue_size = frappe.db.get_single_value("Accounts Settings", "reconciliation_queue_size") or 5
|
||||
queue_size = frappe.get_settings("Accounts Settings", "reconciliation_queue_size") or 5
|
||||
|
||||
fields = ["company", "party_type", "party", "receivable_payable_account", "default_advance_account"]
|
||||
|
||||
|
||||
@@ -1729,7 +1729,7 @@ class PurchaseInvoice(BuyingController):
|
||||
frappe.throw(_("Supplier Invoice Date cannot be greater than Posting Date"))
|
||||
|
||||
if self.bill_no:
|
||||
if cint(frappe.db.get_single_value("Accounts Settings", "check_supplier_invoice_uniqueness")):
|
||||
if cint(frappe.get_settings("Accounts Settings", "check_supplier_invoice_uniqueness")):
|
||||
fiscal_year = get_fiscal_year(self.posting_date, company=self.company, as_dict=True)
|
||||
|
||||
pi = frappe.db.sql(
|
||||
|
||||
@@ -1096,9 +1096,7 @@ class SalesInvoice(SellingController):
|
||||
if self.is_created_using_pos and not self.pos_profile:
|
||||
frappe.throw(_("POS Profile is mandatory to mark this invoice as POS Transaction."))
|
||||
|
||||
self.is_pos_using_sales_invoice = frappe.db.get_single_value(
|
||||
"Accounts Settings", "use_sales_invoice_in_pos"
|
||||
)
|
||||
self.is_pos_using_sales_invoice = frappe.get_settings("Accounts Settings", "use_sales_invoice_in_pos")
|
||||
if not self.is_pos_using_sales_invoice and not self.is_return:
|
||||
frappe.throw(_("Transactions using Sales Invoice in POS are disabled."))
|
||||
|
||||
@@ -1635,7 +1633,7 @@ class SalesInvoice(SellingController):
|
||||
def make_pos_gl_entries(self, gl_entries):
|
||||
if cint(self.is_pos):
|
||||
skip_change_gl_entries = not cint(
|
||||
frappe.db.get_single_value("Accounts Settings", "post_change_gl_entries")
|
||||
frappe.get_settings("Accounts Settings", "post_change_gl_entries")
|
||||
)
|
||||
|
||||
for payment_mode in self.payments:
|
||||
@@ -2920,7 +2918,7 @@ def check_if_return_invoice_linked_with_payment_entry(self):
|
||||
# If a Return invoice is linked with payment entry along with other invoices,
|
||||
# the cancellation of the Return causes allocated amount to be greater than paid
|
||||
|
||||
if not frappe.db.get_single_value("Accounts Settings", "unlink_payment_on_cancellation_of_invoice"):
|
||||
if not frappe.get_settings("Accounts Settings", "unlink_payment_on_cancellation_of_invoice"):
|
||||
return
|
||||
|
||||
payment_entries = []
|
||||
|
||||
@@ -35,7 +35,7 @@ def make_gl_entries(
|
||||
):
|
||||
if gl_map:
|
||||
if (
|
||||
frappe.db.get_single_value("Accounts Settings", "use_new_budget_controller")
|
||||
frappe.get_settings("Accounts Settings", "use_new_budget_controller")
|
||||
and gl_map[0].voucher_type != "Period Closing Voucher"
|
||||
):
|
||||
bud_val = BudgetValidation(gl_map=gl_map)
|
||||
@@ -743,11 +743,9 @@ def check_freezing_date(posting_date, adv_adj=False):
|
||||
Hence stop admin to bypass if accounts are freezed
|
||||
"""
|
||||
if not adv_adj:
|
||||
acc_frozen_upto = frappe.db.get_single_value("Accounts Settings", "acc_frozen_upto")
|
||||
acc_frozen_upto = frappe.get_settings("Accounts Settings", "acc_frozen_upto")
|
||||
if acc_frozen_upto:
|
||||
frozen_accounts_modifier = frappe.db.get_single_value(
|
||||
"Accounts Settings", "frozen_accounts_modifier"
|
||||
)
|
||||
frozen_accounts_modifier = frappe.get_settings("Accounts Settings", "frozen_accounts_modifier")
|
||||
if getdate(posting_date) <= getdate(acc_frozen_upto) and (
|
||||
frozen_accounts_modifier not in frappe.get_roles() or frappe.session.user == "Administrator"
|
||||
):
|
||||
@@ -825,4 +823,4 @@ def validate_allowed_dimensions(gl_entry, dimension_filter_map):
|
||||
|
||||
|
||||
def is_immutable_ledger_enabled():
|
||||
return frappe.db.get_single_value("Accounts Settings", "enable_immutable_ledger")
|
||||
return frappe.get_settings("Accounts Settings", "enable_immutable_ledger")
|
||||
|
||||
@@ -689,7 +689,7 @@ def validate_due_date_with_template(posting_date, due_date, bill_date, template_
|
||||
return
|
||||
|
||||
if default_due_date != posting_date and getdate(due_date) > getdate(default_due_date):
|
||||
if frappe.db.get_single_value("Accounts Settings", "credit_controller") in frappe.get_roles():
|
||||
if frappe.get_settings("Accounts Settings", "credit_controller") in frappe.get_roles():
|
||||
party_type = "supplier" if doctype == "Purchase Invoice" else "customer"
|
||||
|
||||
msgprint(
|
||||
@@ -703,9 +703,7 @@ def validate_due_date_with_template(posting_date, due_date, bill_date, template_
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_address_tax_category(tax_category=None, billing_address=None, shipping_address=None):
|
||||
addr_tax_category_from = frappe.db.get_single_value(
|
||||
"Accounts Settings", "determine_address_tax_category_from"
|
||||
)
|
||||
addr_tax_category_from = frappe.get_settings("Accounts Settings", "determine_address_tax_category_from")
|
||||
if addr_tax_category_from == "Shipping Address":
|
||||
if shipping_address:
|
||||
tax_category = frappe.db.get_value("Address", shipping_address, "tax_category") or tax_category
|
||||
@@ -803,7 +801,7 @@ def validate_party_frozen_disabled(party_type, party_name):
|
||||
if party.disabled:
|
||||
frappe.throw(_("{0} {1} is disabled").format(party_type, party_name), PartyDisabled)
|
||||
elif party.get("is_frozen"):
|
||||
frozen_accounts_modifier = frappe.db.get_single_value(
|
||||
frozen_accounts_modifier = frappe.get_settings(
|
||||
"Accounts Settings", "frozen_accounts_modifier"
|
||||
)
|
||||
if frozen_accounts_modifier not in frappe.get_roles():
|
||||
|
||||
@@ -57,8 +57,7 @@ class ReceivablePayableReport:
|
||||
self.ranges = [num.strip() for num in self.filters.range.split(",") if num.strip().isdigit()]
|
||||
self.range_numbers = [num for num in range(1, len(self.ranges) + 2)]
|
||||
self.ple_fetch_method = (
|
||||
frappe.db.get_single_value("Accounts Settings", "receivable_payable_fetch_method")
|
||||
or "Buffered Cursor"
|
||||
frappe.get_settings("Accounts Settings", "receivable_payable_fetch_method") or "Buffered Cursor"
|
||||
) # Fail Safe
|
||||
|
||||
def run(self, args):
|
||||
@@ -849,7 +848,7 @@ class ReceivablePayableReport:
|
||||
)
|
||||
|
||||
if self.filters.get("show_remarks"):
|
||||
if remarks_length := frappe.db.get_single_value(
|
||||
if remarks_length := frappe.get_settings(
|
||||
"Accounts Settings", "receivable_payable_remarks_length"
|
||||
):
|
||||
query = query.select(Substring(ple.remarks, 1, remarks_length).as_("remarks"))
|
||||
|
||||
@@ -435,9 +435,7 @@ def set_gl_entries_by_account(
|
||||
gl_entries = []
|
||||
|
||||
# For balance sheet
|
||||
ignore_closing_balances = frappe.db.get_single_value(
|
||||
"Accounts Settings", "ignore_account_closing_balance"
|
||||
)
|
||||
ignore_closing_balances = frappe.get_settings("Accounts Settings", "ignore_account_closing_balance")
|
||||
if not from_date and not ignore_closing_balances:
|
||||
last_period_closing_voucher = frappe.db.get_all(
|
||||
"Period Closing Voucher",
|
||||
@@ -519,9 +517,7 @@ def get_accounting_entries(
|
||||
.where(gl_entry.company == filters.company)
|
||||
)
|
||||
|
||||
ignore_is_opening = frappe.db.get_single_value(
|
||||
"Accounts Settings", "ignore_is_opening_check_for_reporting"
|
||||
)
|
||||
ignore_is_opening = frappe.get_settings("Accounts Settings", "ignore_is_opening_check_for_reporting")
|
||||
|
||||
if doctype == "GL Entry":
|
||||
query = query.select(gl_entry.posting_date, gl_entry.is_opening, gl_entry.fiscal_year)
|
||||
|
||||
@@ -163,7 +163,7 @@ def get_gl_entries(filters, accounting_dimensions):
|
||||
credit_in_account_currency """
|
||||
|
||||
if filters.get("show_remarks"):
|
||||
if remarks_length := frappe.db.get_single_value("Accounts Settings", "general_ledger_remarks_length"):
|
||||
if remarks_length := frappe.get_settings("Accounts Settings", "general_ledger_remarks_length"):
|
||||
select_fields += f",substr(remarks, 1, {remarks_length}) as 'remarks'"
|
||||
else:
|
||||
select_fields += """,remarks"""
|
||||
@@ -218,9 +218,7 @@ def get_gl_entries(filters, accounting_dimensions):
|
||||
def get_conditions(filters):
|
||||
conditions = []
|
||||
|
||||
ignore_is_opening = frappe.db.get_single_value(
|
||||
"Accounts Settings", "ignore_is_opening_check_for_reporting"
|
||||
)
|
||||
ignore_is_opening = frappe.get_settings("Accounts Settings", "ignore_is_opening_check_for_reporting")
|
||||
|
||||
if filters.get("account"):
|
||||
filters.account = get_accounts_with_children(filters.account)
|
||||
@@ -480,7 +478,7 @@ def get_accountwise_gle(filters, accounting_dimensions, gl_entries, gle_map):
|
||||
if filters.get("show_net_values_in_party_account"):
|
||||
account_type_map = get_account_type_map(filters.get("company"))
|
||||
|
||||
immutable_ledger = frappe.db.get_single_value("Accounts Settings", "enable_immutable_ledger")
|
||||
immutable_ledger = frappe.get_settings("Accounts Settings", "enable_immutable_ledger")
|
||||
|
||||
def update_value_in_dict(data, key, gle):
|
||||
data[key].debit += gle.debit
|
||||
|
||||
@@ -89,9 +89,7 @@ def get_data(filters):
|
||||
)
|
||||
company_currency = filters.presentation_currency or erpnext.get_company_currency(filters.company)
|
||||
|
||||
ignore_is_opening = frappe.db.get_single_value(
|
||||
"Accounts Settings", "ignore_is_opening_check_for_reporting"
|
||||
)
|
||||
ignore_is_opening = frappe.get_settings("Accounts Settings", "ignore_is_opening_check_for_reporting")
|
||||
|
||||
if not accounts:
|
||||
return None
|
||||
@@ -148,9 +146,7 @@ def get_rootwise_opening_balances(filters, report_type, ignore_is_opening):
|
||||
gle = []
|
||||
|
||||
last_period_closing_voucher = ""
|
||||
ignore_closing_balances = frappe.db.get_single_value(
|
||||
"Accounts Settings", "ignore_account_closing_balance"
|
||||
)
|
||||
ignore_closing_balances = frappe.get_settings("Accounts Settings", "ignore_account_closing_balance")
|
||||
|
||||
if not ignore_closing_balances:
|
||||
last_period_closing_voucher = frappe.db.get_all(
|
||||
|
||||
@@ -886,7 +886,7 @@ def cancel_common_party_journal(self):
|
||||
if self.doctype not in ["Sales Invoice", "Purchase Invoice"]:
|
||||
return
|
||||
|
||||
if not frappe.db.get_single_value("Accounts Settings", "enable_common_party_accounting"):
|
||||
if not frappe.get_settings("Accounts Settings", "enable_common_party_accounting"):
|
||||
return
|
||||
|
||||
party_link = self.get_common_party_link()
|
||||
@@ -2312,7 +2312,7 @@ def run_ledger_health_checks():
|
||||
|
||||
|
||||
def sync_auto_reconcile_config(auto_reconciliation_job_trigger: int = 15):
|
||||
auto_reconciliation_job_trigger = auto_reconciliation_job_trigger or frappe.db.get_single_value(
|
||||
auto_reconciliation_job_trigger = auto_reconciliation_job_trigger or frappe.get_settings(
|
||||
"Accounts Settings", "auto_reconciliation_job_trigger"
|
||||
)
|
||||
method = "erpnext.accounts.doctype.process_payment_reconciliation.process_payment_reconciliation.trigger_reconciliation_for_queued_docs"
|
||||
|
||||
@@ -35,9 +35,7 @@ from erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_sched
|
||||
|
||||
def post_depreciation_entries(date=None):
|
||||
# Return if automatic booking of asset depreciation is disabled
|
||||
if not cint(
|
||||
frappe.db.get_single_value("Accounts Settings", "book_asset_depreciation_entry_automatically")
|
||||
):
|
||||
if not cint(frappe.get_settings("Accounts Settings", "book_asset_depreciation_entry_automatically")):
|
||||
return
|
||||
|
||||
date = date or today()
|
||||
@@ -114,12 +112,12 @@ def make_depreciation_entry_on_disposal(asset_doc, disposal_date=None):
|
||||
|
||||
|
||||
def get_acc_frozen_upto():
|
||||
acc_frozen_upto = frappe.db.get_single_value("Accounts Settings", "acc_frozen_upto")
|
||||
acc_frozen_upto = frappe.get_settings("Accounts Settings", "acc_frozen_upto")
|
||||
|
||||
if not acc_frozen_upto:
|
||||
return
|
||||
|
||||
frozen_accounts_modifier = frappe.db.get_single_value("Accounts Settings", "frozen_accounts_modifier")
|
||||
frozen_accounts_modifier = frappe.get_settings("Accounts Settings", "frozen_accounts_modifier")
|
||||
|
||||
if frozen_accounts_modifier not in frappe.get_roles() or frappe.session.user == "Administrator":
|
||||
return getdate(acc_frozen_upto)
|
||||
|
||||
@@ -251,7 +251,7 @@ class DepreciationScheduleController(StraightLineMethod, WDVMethod):
|
||||
return depr_booked_for_months
|
||||
|
||||
def get_total_pending_days_or_years(self):
|
||||
if cint(frappe.db.get_single_value("Accounts Settings", "calculate_depr_using_total_days")):
|
||||
if cint(frappe.get_settings("Accounts Settings", "calculate_depr_using_total_days")):
|
||||
last_depr_date = self.get_last_booked_depreciation_date()
|
||||
if last_depr_date:
|
||||
self.total_pending_days = date_diff(self.final_schedule_date, last_depr_date) - 1
|
||||
|
||||
@@ -38,7 +38,7 @@ class StraightLineMethod(Document):
|
||||
return daily_depr_amount * total_depreciable_days
|
||||
|
||||
def get_daily_depr_amount(self):
|
||||
if cint(frappe.db.get_single_value("Accounts Settings", "calculate_depr_using_total_days")):
|
||||
if cint(frappe.get_settings("Accounts Settings", "calculate_depr_using_total_days")):
|
||||
return self.depreciable_value / self.total_pending_days
|
||||
else:
|
||||
yearly_depr_amount = self.depreciable_value / self.total_pending_years
|
||||
|
||||
@@ -403,7 +403,7 @@ class AccountsController(TransactionBase):
|
||||
self.remove_serial_and_batch_bundle()
|
||||
|
||||
# delete sl and gl entries on deletion of transaction
|
||||
if frappe.db.get_single_value("Accounts Settings", "delete_linked_ledger_entries"):
|
||||
if frappe.get_settings("Accounts Settings", "delete_linked_ledger_entries"):
|
||||
# delete linked exchange gain/loss journal
|
||||
delete_exchange_gain_loss_journal(self)
|
||||
|
||||
@@ -744,9 +744,7 @@ class AccountsController(TransactionBase):
|
||||
frappe.throw(_(msg), title=_("Internal Transfer Reference Missing"))
|
||||
|
||||
def validate_internal_transaction(self):
|
||||
if not cint(
|
||||
frappe.db.get_single_value("Accounts Settings", "maintain_same_internal_transaction_rate")
|
||||
):
|
||||
if not cint(frappe.get_settings("Accounts Settings", "maintain_same_internal_transaction_rate")):
|
||||
return
|
||||
|
||||
doctypes_list = ["Sales Order", "Sales Invoice", "Purchase Order", "Purchase Invoice"]
|
||||
@@ -1143,7 +1141,7 @@ class AccountsController(TransactionBase):
|
||||
return True
|
||||
|
||||
def set_taxes_and_charges(self):
|
||||
if frappe.db.get_single_value("Accounts Settings", "add_taxes_from_item_tax_template"):
|
||||
if frappe.get_settings("Accounts Settings", "add_taxes_from_item_tax_template"):
|
||||
if hasattr(self, "taxes_and_charges") and not self.get("taxes") and not self.get("is_pos"):
|
||||
if tax_master_doctype := self.meta.get_field("taxes_and_charges").options:
|
||||
self.append_taxes_from_master(tax_master_doctype)
|
||||
@@ -1156,7 +1154,7 @@ class AccountsController(TransactionBase):
|
||||
self.extend("taxes", get_taxes_and_charges(tax_master_doctype, self.get("taxes_and_charges")))
|
||||
|
||||
def append_taxes_from_item_tax_template(self):
|
||||
if not frappe.db.get_single_value("Accounts Settings", "add_taxes_from_item_tax_template"):
|
||||
if not frappe.get_settings("Accounts Settings", "add_taxes_from_item_tax_template"):
|
||||
return
|
||||
|
||||
for row in self.items:
|
||||
@@ -1497,7 +1495,7 @@ class AccountsController(TransactionBase):
|
||||
return res
|
||||
|
||||
def is_inclusive_tax(self):
|
||||
is_inclusive = cint(frappe.db.get_single_value("Accounts Settings", "show_inclusive_tax_in_print"))
|
||||
is_inclusive = cint(frappe.get_settings("Accounts Settings", "show_inclusive_tax_in_print"))
|
||||
|
||||
if is_inclusive:
|
||||
is_inclusive = 0
|
||||
@@ -1507,7 +1505,7 @@ class AccountsController(TransactionBase):
|
||||
return is_inclusive
|
||||
|
||||
def should_show_taxes_as_table_in_print(self):
|
||||
return cint(frappe.db.get_single_value("Accounts Settings", "show_taxes_as_table_in_print"))
|
||||
return cint(frappe.get_settings("Accounts Settings", "show_taxes_as_table_in_print"))
|
||||
|
||||
def validate_advance_entries(self):
|
||||
order_field = "sales_order" if self.doctype == "Sales Invoice" else "purchase_order"
|
||||
@@ -1884,13 +1882,11 @@ class AccountsController(TransactionBase):
|
||||
cancel_exchange_gain_loss_journal(self)
|
||||
cancel_common_party_journal(self)
|
||||
|
||||
if frappe.db.get_single_value("Accounts Settings", "unlink_payment_on_cancellation_of_invoice"):
|
||||
if frappe.get_settings("Accounts Settings", "unlink_payment_on_cancellation_of_invoice"):
|
||||
unlink_ref_doc_from_payment_entries(self)
|
||||
|
||||
elif self.doctype in ["Sales Order", "Purchase Order"]:
|
||||
if frappe.db.get_single_value(
|
||||
"Accounts Settings", "unlink_advance_payment_on_cancelation_of_order"
|
||||
):
|
||||
if frappe.get_settings("Accounts Settings", "unlink_advance_payment_on_cancelation_of_order"):
|
||||
unlink_ref_doc_from_payment_entries(self)
|
||||
|
||||
if self.doctype == "Sales Order":
|
||||
@@ -2448,7 +2444,7 @@ class AccountsController(TransactionBase):
|
||||
grand_total = grand_total - flt(self.write_off_amount)
|
||||
po_or_so, doctype, fieldname = self.get_order_details()
|
||||
automatically_fetch_payment_terms = cint(
|
||||
frappe.db.get_single_value("Accounts Settings", "automatically_fetch_payment_terms")
|
||||
frappe.get_settings("Accounts Settings", "automatically_fetch_payment_terms")
|
||||
)
|
||||
|
||||
if self.get("total_advance"):
|
||||
@@ -2731,7 +2727,7 @@ class AccountsController(TransactionBase):
|
||||
if not is_invoice:
|
||||
return
|
||||
|
||||
if frappe.db.get_single_value("Accounts Settings", "enable_common_party_accounting"):
|
||||
if frappe.get_settings("Accounts Settings", "enable_common_party_accounting"):
|
||||
party_link = self.get_common_party_link()
|
||||
if party_link and self.outstanding_amount:
|
||||
self.create_advance_and_reconcile(party_link)
|
||||
@@ -3517,7 +3513,7 @@ def set_child_tax_template_and_map(item, child_item, parent_doc):
|
||||
|
||||
|
||||
def add_taxes_from_tax_template(child_item, parent_doc, db_insert=True):
|
||||
add_taxes_from_item_tax_template = frappe.db.get_single_value(
|
||||
add_taxes_from_item_tax_template = frappe.get_settings(
|
||||
"Accounts Settings", "add_taxes_from_item_tax_template"
|
||||
)
|
||||
|
||||
|
||||
@@ -842,7 +842,7 @@ class BuyingController(SubcontractingController):
|
||||
self.update_fixed_asset(field, delete_asset=True)
|
||||
|
||||
def validate_budget(self):
|
||||
if frappe.db.get_single_value("Accounts Settings", "use_new_budget_controller"):
|
||||
if frappe.get_settings("Accounts Settings", "use_new_budget_controller"):
|
||||
from erpnext.controllers.budget_controller import BudgetValidation
|
||||
|
||||
val = BudgetValidation(doc=self)
|
||||
|
||||
@@ -339,9 +339,7 @@ class StatusUpdater(Document):
|
||||
role_allowed_to_over_deliver_receive = frappe.get_settings(
|
||||
"Stock Settings", "role_allowed_to_over_deliver_receive"
|
||||
)
|
||||
role_allowed_to_over_bill = frappe.db.get_single_value(
|
||||
"Accounts Settings", "role_allowed_to_over_bill"
|
||||
)
|
||||
role_allowed_to_over_bill = frappe.get_settings("Accounts Settings", "role_allowed_to_over_bill")
|
||||
role = role_allowed_to_over_deliver_receive if qty_or_amount == "qty" else role_allowed_to_over_bill
|
||||
|
||||
overflow_percent = (
|
||||
|
||||
@@ -28,9 +28,7 @@ class calculate_taxes_and_totals:
|
||||
def __init__(self, doc: Document):
|
||||
self.doc = doc
|
||||
frappe.flags.round_off_applicable_accounts = []
|
||||
frappe.flags.round_row_wise_tax = frappe.db.get_single_value(
|
||||
"Accounts Settings", "round_row_wise_tax"
|
||||
)
|
||||
frappe.flags.round_row_wise_tax = frappe.get_settings("Accounts Settings", "round_row_wise_tax")
|
||||
|
||||
if doc.get("round_off_applicable_accounts_for_tax_withholding"):
|
||||
frappe.flags.round_off_applicable_accounts.append(
|
||||
@@ -1170,7 +1168,7 @@ def get_rounded_tax_amount(itemised_tax, precision):
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_rounding_tax_settings():
|
||||
return frappe.db.get_single_value("Accounts Settings", "round_row_wise_tax")
|
||||
return frappe.get_settings("Accounts Settings", "round_row_wise_tax")
|
||||
|
||||
|
||||
class init_landed_taxes_and_totals:
|
||||
|
||||
@@ -554,7 +554,7 @@ def check_credit_limit(customer, company, ignore_outstanding_sales_order=False,
|
||||
message += "<br><br>"
|
||||
|
||||
# If not authorized person raise exception
|
||||
credit_controller_role = frappe.db.get_single_value("Accounts Settings", "credit_controller")
|
||||
credit_controller_role = frappe.get_settings("Accounts Settings", "credit_controller")
|
||||
if not credit_controller_role or credit_controller_role not in frappe.get_roles():
|
||||
# form a list of emails for the credit controller users
|
||||
credit_controller_users = get_users_with_role(credit_controller_role or "Sales Master Manager")
|
||||
|
||||
@@ -1220,7 +1220,7 @@ def make_sales_invoice(source_name, target_doc=None, ignore_permissions=False):
|
||||
)
|
||||
|
||||
automatically_fetch_payment_terms = cint(
|
||||
frappe.db.get_single_value("Accounts Settings", "automatically_fetch_payment_terms")
|
||||
frappe.get_settings("Accounts Settings", "automatically_fetch_payment_terms")
|
||||
)
|
||||
if automatically_fetch_payment_terms:
|
||||
doclist.set_payment_schedule()
|
||||
|
||||
@@ -20,10 +20,8 @@ def boot_session(bootinfo):
|
||||
bootinfo.sysdefaults.use_server_side_reactivity = frappe.db.get_single_value(
|
||||
"Selling Settings", "use_server_side_reactivity"
|
||||
)
|
||||
bootinfo.sysdefaults.allow_stale = cint(
|
||||
frappe.db.get_single_value("Accounts Settings", "allow_stale")
|
||||
)
|
||||
bootinfo.sysdefaults.over_billing_allowance = frappe.db.get_single_value(
|
||||
bootinfo.sysdefaults.allow_stale = cint(frappe.get_settings("Accounts Settings", "allow_stale"))
|
||||
bootinfo.sysdefaults.over_billing_allowance = frappe.get_settings(
|
||||
"Accounts Settings", "over_billing_allowance"
|
||||
)
|
||||
|
||||
|
||||
@@ -901,7 +901,7 @@ def make_sales_invoice(source_name, target_doc=None, args=None):
|
||||
)
|
||||
|
||||
automatically_fetch_payment_terms = cint(
|
||||
frappe.db.get_single_value("Accounts Settings", "automatically_fetch_payment_terms")
|
||||
frappe.get_settings("Accounts Settings", "automatically_fetch_payment_terms")
|
||||
)
|
||||
if automatically_fetch_payment_terms and not doc.is_return:
|
||||
doc.set_payment_schedule()
|
||||
|
||||
@@ -1199,7 +1199,7 @@ def get_billed_amount_against_po(po_items):
|
||||
def update_billing_percentage(pr_doc, update_modified=True, adjust_incoming_rate=False):
|
||||
# Update Billing % based on pending accepted qty
|
||||
buying_settings = frappe.get_single("Buying Settings")
|
||||
over_billing_allowance = frappe.db.get_single_value("Accounts Settings", "over_billing_allowance")
|
||||
over_billing_allowance = frappe.get_settings("Accounts Settings", "over_billing_allowance")
|
||||
|
||||
total_amount, total_billed_amount = 0, 0
|
||||
item_wise_returned_qty = get_item_wise_returned_qty(pr_doc)
|
||||
|
||||
@@ -354,7 +354,7 @@ class TransactionBase(StatusUpdater):
|
||||
self.set_rate_based_on_price_list(item_obj, item_details)
|
||||
|
||||
def add_taxes_from_item_template(self, item_obj: object, item_details: dict) -> None:
|
||||
if item_details.item_tax_rate and frappe.db.get_single_value(
|
||||
if item_details.item_tax_rate and frappe.get_settings(
|
||||
"Accounts Settings", "add_taxes_from_item_tax_template"
|
||||
):
|
||||
item_tax_template = frappe.json.loads(item_details.item_tax_rate)
|
||||
|
||||
Reference in New Issue
Block a user