mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-13 01:34:10 +00:00
fix: validate budget after cost center allocation
(cherry picked from commit f9be8a46fb)
This commit is contained in:
@@ -199,19 +199,20 @@ def distribute_gl_based_on_cost_center_allocation(gl_map, precision=None, from_r
|
|||||||
for d in gl_map:
|
for d in gl_map:
|
||||||
cost_center = d.get("cost_center")
|
cost_center = d.get("cost_center")
|
||||||
|
|
||||||
|
cost_center_allocation = get_cost_center_allocation_data(
|
||||||
|
gl_map[0]["company"], gl_map[0]["posting_date"], cost_center
|
||||||
|
)
|
||||||
|
|
||||||
|
if not cost_center_allocation:
|
||||||
|
new_gl_map.append(d)
|
||||||
|
continue
|
||||||
|
|
||||||
# Validate budget against main cost center
|
# Validate budget against main cost center
|
||||||
if not from_repost:
|
if not from_repost:
|
||||||
validate_expense_against_budget(
|
validate_expense_against_budget(
|
||||||
d, expense_amount=flt(d.debit, precision) - flt(d.credit, precision)
|
d, expense_amount=flt(d.debit, precision) - flt(d.credit, precision)
|
||||||
)
|
)
|
||||||
|
|
||||||
cost_center_allocation = get_cost_center_allocation_data(
|
|
||||||
gl_map[0]["company"], gl_map[0]["posting_date"], cost_center
|
|
||||||
)
|
|
||||||
if not cost_center_allocation:
|
|
||||||
new_gl_map.append(d)
|
|
||||||
continue
|
|
||||||
|
|
||||||
if d.account == round_off_account:
|
if d.account == round_off_account:
|
||||||
d.cost_center = cost_center_allocation[0][0]
|
d.cost_center = cost_center_allocation[0][0]
|
||||||
new_gl_map.append(d)
|
new_gl_map.append(d)
|
||||||
@@ -414,7 +415,11 @@ def make_entry(args, adv_adj, update_outstanding, from_repost=False):
|
|||||||
gle.flags.notify_update = False
|
gle.flags.notify_update = False
|
||||||
gle.submit()
|
gle.submit()
|
||||||
|
|
||||||
if not from_repost and gle.voucher_type != "Period Closing Voucher":
|
if (
|
||||||
|
not from_repost
|
||||||
|
and gle.voucher_type != "Period Closing Voucher"
|
||||||
|
and (gle.is_cancelled == 0 or gle.voucher_type == "Journal Entry")
|
||||||
|
):
|
||||||
validate_expense_against_budget(args)
|
validate_expense_against_budget(args)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user