Skip to content

Commit

Permalink
fix: Check if accounting dimension exists
Browse files Browse the repository at this point in the history
(cherry picked from commit c312cd3)
  • Loading branch information
deepeshgarg007 authored and mergify-bot committed Apr 25, 2022
1 parent dedb90e commit 1834671
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions erpnext/accounts/general_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,21 +318,31 @@ def make_round_off_gle(gl_map, debit_credit_diff, precision):

def update_accounting_dimensions(round_off_gle):
dimensions = get_accounting_dimensions()
dimension_values = frappe.db.get_value(
round_off_gle["voucher_type"], round_off_gle["voucher_no"], dimensions
)
meta = frappe.get_meta(round_off_gle["voucher_type"])
has_all_dimensions = True

for dimension in dimensions:
round_off_gle[dimension] = dimension_values.get(dimension)
if not meta.has_field(dimension):
has_all_dimensions = False

if dimensions and has_all_dimensions:
dimension_values = frappe.db.get_value(
round_off_gle["voucher_type"], round_off_gle["voucher_no"], dimensions
)

for dimension in dimensions:
round_off_gle[dimension] = dimension_values.get(dimension)


def get_round_off_account_and_cost_center(company, voucher_type, voucher_no):
round_off_account, round_off_cost_center = frappe.get_cached_value(
"Company", company, ["round_off_account", "round_off_cost_center"]
) or [None, None]

meta = frappe.get_meta(voucher_type)

# Give first preference to parent cost center for round off GLE
if frappe.db.has_column(voucher_type, "cost_center"):
if meta.has_field("cost_center"):
parent_cost_center = frappe.db.get_value(voucher_type, voucher_no, "cost_center")
if parent_cost_center:
round_off_cost_center = parent_cost_center
Expand Down

0 comments on commit 1834671

Please sign in to comment.