mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-05 13:24:47 +00:00
refactor: validate on GL creation
This commit is contained in:
@@ -20,6 +20,7 @@ from erpnext.accounts.doctype.accounting_dimension_filter.accounting_dimension_f
|
|||||||
from erpnext.accounts.doctype.accounting_period.accounting_period import ClosedAccountingPeriod
|
from erpnext.accounts.doctype.accounting_period.accounting_period import ClosedAccountingPeriod
|
||||||
from erpnext.accounts.doctype.budget.budget import validate_expense_against_budget
|
from erpnext.accounts.doctype.budget.budget import validate_expense_against_budget
|
||||||
from erpnext.accounts.utils import create_payment_ledger_entry
|
from erpnext.accounts.utils import create_payment_ledger_entry
|
||||||
|
from erpnext.controllers.budget_controller import BudgetValidation
|
||||||
from erpnext.exceptions import InvalidAccountDimensionError, MandatoryAccountDimensionError
|
from erpnext.exceptions import InvalidAccountDimensionError, MandatoryAccountDimensionError
|
||||||
|
|
||||||
|
|
||||||
@@ -39,6 +40,9 @@ def make_gl_entries(
|
|||||||
gl_map = process_gl_map(gl_map, merge_entries, from_repost=from_repost)
|
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":
|
||||||
|
bud_val = BudgetValidation(gl_map=gl_map)
|
||||||
|
bud_val.validate()
|
||||||
|
|
||||||
create_payment_ledger_entry(
|
create_payment_ledger_entry(
|
||||||
gl_map,
|
gl_map,
|
||||||
cancel=0,
|
cancel=0,
|
||||||
@@ -191,11 +195,12 @@ 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")
|
||||||
|
|
||||||
|
# TODO: is a separate validation on cost center allocation required?
|
||||||
# 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(
|
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
|
||||||
@@ -397,8 +402,8 @@ 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":
|
||||||
validate_expense_against_budget(args)
|
# validate_expense_against_budget(args)
|
||||||
|
|
||||||
|
|
||||||
def validate_cwip_accounts(gl_map):
|
def validate_cwip_accounts(gl_map):
|
||||||
|
|||||||
Reference in New Issue
Block a user