Skip to content

Commit

Permalink
fix: First preference to parent cost center rather than round off cos…
Browse files Browse the repository at this point in the history
…t center

(cherry picked from commit 0ac11a5)
  • Loading branch information
deepeshgarg007 authored and mergify-bot committed Apr 25, 2022
1 parent f70fca1 commit a2d95fc
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions erpnext/accounts/general_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def round_off_debit_credit(gl_map):

def make_round_off_gle(gl_map, debit_credit_diff, precision):
round_off_account, round_off_cost_center = get_round_off_account_and_cost_center(
gl_map[0].company
gl_map[0].company, gl_map[0].voucher_type, gl_map[0].voucher_no
)
round_off_account_exists = False
round_off_gle = frappe._dict()
Expand Down Expand Up @@ -314,10 +314,17 @@ def make_round_off_gle(gl_map, debit_credit_diff, precision):
gl_map.append(round_off_gle)


def get_round_off_account_and_cost_center(company):
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]

# Give first preference to parent cost center for round off GLE
if frappe.db.has_column(voucher_type, "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

if not round_off_account:
frappe.throw(_("Please mention Round Off Account in Company"))

Expand Down

0 comments on commit a2d95fc

Please sign in to comment.