mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-18 20:49:19 +00:00
fix(test): dormant broken test in Budget
This commit is contained in:
@@ -510,7 +510,7 @@ def get_accumulated_monthly_budget(monthly_distribution, posting_date, fiscal_ye
|
|||||||
accumulated_percentage = 0.0
|
accumulated_percentage = 0.0
|
||||||
|
|
||||||
while dt <= getdate(posting_date):
|
while dt <= getdate(posting_date):
|
||||||
if monthly_distribution:
|
if monthly_distribution and distribution:
|
||||||
accumulated_percentage += distribution.get(getdate(dt).strftime("%B"), 0)
|
accumulated_percentage += distribution.get(getdate(dt).strftime("%B"), 0)
|
||||||
else:
|
else:
|
||||||
accumulated_percentage += 100.0 / 12
|
accumulated_percentage += 100.0 / 12
|
||||||
|
|||||||
@@ -5,7 +5,11 @@ import unittest
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import now_datetime, nowdate
|
from frappe.utils import now_datetime, nowdate
|
||||||
|
|
||||||
from erpnext.accounts.doctype.budget.budget import BudgetError, get_actual_expense
|
from erpnext.accounts.doctype.budget.budget import (
|
||||||
|
BudgetError,
|
||||||
|
get_accumulated_monthly_budget,
|
||||||
|
get_actual_expense,
|
||||||
|
)
|
||||||
from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry
|
from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry
|
||||||
from erpnext.accounts.utils import get_fiscal_year
|
from erpnext.accounts.utils import get_fiscal_year
|
||||||
from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order
|
from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order
|
||||||
@@ -67,10 +71,13 @@ class TestBudget(ERPNextTestSuite):
|
|||||||
|
|
||||||
frappe.db.set_value("Budget", budget.name, "action_if_accumulated_monthly_budget_exceeded", "Stop")
|
frappe.db.set_value("Budget", budget.name, "action_if_accumulated_monthly_budget_exceeded", "Stop")
|
||||||
|
|
||||||
|
accumulated_limit = get_accumulated_monthly_budget(
|
||||||
|
budget.monthly_distribution, nowdate(), budget.fiscal_year, budget.accounts[0].budget_amount
|
||||||
|
)
|
||||||
jv = make_journal_entry(
|
jv = make_journal_entry(
|
||||||
"_Test Account Cost for Goods Sold - _TC",
|
"_Test Account Cost for Goods Sold - _TC",
|
||||||
"_Test Bank - _TC",
|
"_Test Bank - _TC",
|
||||||
40000,
|
accumulated_limit + 1,
|
||||||
"_Test Cost Center - _TC",
|
"_Test Cost Center - _TC",
|
||||||
posting_date=nowdate(),
|
posting_date=nowdate(),
|
||||||
)
|
)
|
||||||
@@ -427,6 +434,7 @@ def make_budget(**args):
|
|||||||
|
|
||||||
monthly_distribution = frappe.get_doc("Monthly Distribution", "_Test Distribution")
|
monthly_distribution = frappe.get_doc("Monthly Distribution", "_Test Distribution")
|
||||||
monthly_distribution.fiscal_year = fiscal_year
|
monthly_distribution.fiscal_year = fiscal_year
|
||||||
|
monthly_distribution.save()
|
||||||
|
|
||||||
budget.fiscal_year = fiscal_year
|
budget.fiscal_year = fiscal_year
|
||||||
budget.monthly_distribution = "_Test Distribution"
|
budget.monthly_distribution = "_Test Distribution"
|
||||||
|
|||||||
Reference in New Issue
Block a user