fix: do not check budget during reposting (#45432)

(cherry picked from commit 53704b98b5)
This commit is contained in:
rohitwaghchaure
2025-01-24 17:30:45 +05:30
committed by Mergify
parent 13c7fceb91
commit f2b946d325

View File

@@ -35,7 +35,7 @@ def make_gl_entries(
make_acc_dimensions_offsetting_entry(gl_map) make_acc_dimensions_offsetting_entry(gl_map)
validate_accounting_period(gl_map) validate_accounting_period(gl_map)
validate_disabled_accounts(gl_map) validate_disabled_accounts(gl_map)
gl_map = process_gl_map(gl_map, merge_entries) gl_map = process_gl_map(gl_map, merge_entries, from_repost=from_repost)
if gl_map and len(gl_map) > 1: if gl_map and len(gl_map) > 1:
if gl_map[0].voucher_type != "Period Closing Voucher": if gl_map[0].voucher_type != "Period Closing Voucher":
create_payment_ledger_entry( create_payment_ledger_entry(
@@ -163,12 +163,12 @@ def validate_accounting_period(gl_map):
) )
def process_gl_map(gl_map, merge_entries=True, precision=None): def process_gl_map(gl_map, merge_entries=True, precision=None, from_repost=False):
if not gl_map: if not gl_map:
return [] return []
if gl_map[0].voucher_type != "Period Closing Voucher": if gl_map[0].voucher_type != "Period Closing Voucher":
gl_map = distribute_gl_based_on_cost_center_allocation(gl_map, precision) gl_map = distribute_gl_based_on_cost_center_allocation(gl_map, precision, from_repost)
if merge_entries: if merge_entries:
gl_map = merge_similar_entries(gl_map, precision) gl_map = merge_similar_entries(gl_map, precision)
@@ -178,13 +178,17 @@ def process_gl_map(gl_map, merge_entries=True, precision=None):
return gl_map return gl_map
def distribute_gl_based_on_cost_center_allocation(gl_map, precision=None): def distribute_gl_based_on_cost_center_allocation(gl_map, precision=None, from_repost=False):
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")
# Validate budget against main cost center # Validate budget against main cost center
validate_expense_against_budget(d, expense_amount=flt(d.debit, precision) - flt(d.credit, precision)) if not from_repost:
validate_expense_against_budget(
d, expense_amount=flt(d.debit, precision) - flt(d.credit, precision)
)
cost_center_allocation = get_cost_center_allocation_data( cost_center_allocation = get_cost_center_allocation_data(
gl_map[0]["company"], gl_map[0]["posting_date"], cost_center gl_map[0]["company"], gl_map[0]["posting_date"], cost_center
) )