mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-10 05:48:15 +00:00
fix: do not split round off when there is a cost center allocation
(cherry picked from commit f0df41d521)
This commit is contained in:
@@ -186,6 +186,15 @@ def process_gl_map(gl_map, merge_entries=True, precision=None, from_repost=False
|
|||||||
|
|
||||||
|
|
||||||
def distribute_gl_based_on_cost_center_allocation(gl_map, precision=None, from_repost=False):
|
def distribute_gl_based_on_cost_center_allocation(gl_map, precision=None, from_repost=False):
|
||||||
|
round_off_account, default_currency = frappe.get_cached_value(
|
||||||
|
"Company", gl_map[0].company, ["round_off_account", "default_currency"]
|
||||||
|
)
|
||||||
|
if not precision:
|
||||||
|
precision = get_field_precision(
|
||||||
|
frappe.get_meta("GL Entry").get_field("debit"),
|
||||||
|
currency=default_currency,
|
||||||
|
)
|
||||||
|
|
||||||
new_gl_map = []
|
new_gl_map = []
|
||||||
for d in gl_map:
|
for d in gl_map:
|
||||||
cost_center = d.get("cost_center")
|
cost_center = d.get("cost_center")
|
||||||
@@ -203,6 +212,11 @@ def distribute_gl_based_on_cost_center_allocation(gl_map, precision=None, from_r
|
|||||||
new_gl_map.append(d)
|
new_gl_map.append(d)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if d.account == round_off_account:
|
||||||
|
d.cost_center = cost_center_allocation[0][0]
|
||||||
|
new_gl_map.append(d)
|
||||||
|
continue
|
||||||
|
|
||||||
for sub_cost_center, percentage in cost_center_allocation:
|
for sub_cost_center, percentage in cost_center_allocation:
|
||||||
gle = copy.deepcopy(d)
|
gle = copy.deepcopy(d)
|
||||||
gle.cost_center = sub_cost_center
|
gle.cost_center = sub_cost_center
|
||||||
|
|||||||
Reference in New Issue
Block a user