mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-23 15:09:20 +00:00
* chore: fix flaky test in Tax Withholding Details (cherry picked from commit14a2f98521) * fix: sort tax withhodling details report by section code and transaction date (cherry picked from commit7ee2418f60) * fix(test): flaky budget test case (cherry picked from commit704223e5d0) * fix(test): import get_accumulated_monthly_budget --------- Co-authored-by: ljain112 <ljain112@gmail.com> Co-authored-by: ruthra kumar <ruthra@erpnext.com> Co-authored-by: diptanilsaha <diptanil@frappe.io>
This commit is contained in:
@@ -6,7 +6,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
|
||||||
@@ -96,6 +100,10 @@ class TestBudget(unittest.TestCase):
|
|||||||
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")
|
||||||
frappe.db.set_value("Budget", budget.name, "fiscal_year", fiscal_year)
|
frappe.db.set_value("Budget", budget.name, "fiscal_year", fiscal_year)
|
||||||
|
|
||||||
|
accumulated_limit = get_accumulated_monthly_budget(
|
||||||
|
budget.monthly_distribution, nowdate(), budget.fiscal_year, budget.accounts[0].budget_amount
|
||||||
|
)
|
||||||
|
|
||||||
mr = frappe.get_doc(
|
mr = frappe.get_doc(
|
||||||
{
|
{
|
||||||
"doctype": "Material Request",
|
"doctype": "Material Request",
|
||||||
@@ -109,7 +117,7 @@ class TestBudget(unittest.TestCase):
|
|||||||
"uom": "_Test UOM",
|
"uom": "_Test UOM",
|
||||||
"warehouse": "_Test Warehouse - _TC",
|
"warehouse": "_Test Warehouse - _TC",
|
||||||
"schedule_date": nowdate(),
|
"schedule_date": nowdate(),
|
||||||
"rate": 100000,
|
"rate": accumulated_limit + 1,
|
||||||
"expense_account": "_Test Account Cost for Goods Sold - _TC",
|
"expense_account": "_Test Account Cost for Goods Sold - _TC",
|
||||||
"cost_center": "_Test Cost Center - _TC",
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ def get_result(filters, tds_docs, tds_accounts, tax_category_map, journal_entry_
|
|||||||
)
|
)
|
||||||
out.append(row)
|
out.append(row)
|
||||||
|
|
||||||
out.sort(key=lambda x: x["section_code"])
|
out.sort(key=lambda x: (x["section_code"], x["transaction_date"]))
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|||||||
@@ -67,11 +67,12 @@ class TestTaxWithholdingDetails(AccountsTestMixin, FrappeTestCase):
|
|||||||
mid_year = add_to_date(fiscal_year[1], months=6)
|
mid_year = add_to_date(fiscal_year[1], months=6)
|
||||||
tds_doc = frappe.get_doc("Tax Withholding Category", "TDS - 3")
|
tds_doc = frappe.get_doc("Tax Withholding Category", "TDS - 3")
|
||||||
tds_doc.rates[0].to_date = mid_year
|
tds_doc.rates[0].to_date = mid_year
|
||||||
|
from_date = add_to_date(mid_year, days=1)
|
||||||
tds_doc.append(
|
tds_doc.append(
|
||||||
"rates",
|
"rates",
|
||||||
{
|
{
|
||||||
"tax_withholding_rate": 20,
|
"tax_withholding_rate": 20,
|
||||||
"from_date": add_to_date(mid_year, days=1),
|
"from_date": from_date,
|
||||||
"to_date": fiscal_year[2],
|
"to_date": fiscal_year[2],
|
||||||
"single_threshold": 1,
|
"single_threshold": 1,
|
||||||
"cumulative_threshold": 1,
|
"cumulative_threshold": 1,
|
||||||
@@ -80,18 +81,19 @@ class TestTaxWithholdingDetails(AccountsTestMixin, FrappeTestCase):
|
|||||||
|
|
||||||
tds_doc.save()
|
tds_doc.save()
|
||||||
|
|
||||||
inv_1 = make_purchase_invoice(rate=1000, do_not_submit=True)
|
inv_1 = make_purchase_invoice(
|
||||||
|
rate=1000, posting_date=add_to_date(fiscal_year[1], days=1), do_not_save=True, do_not_submit=True
|
||||||
|
)
|
||||||
|
inv_1.set_posting_time = 1
|
||||||
inv_1.apply_tds = 1
|
inv_1.apply_tds = 1
|
||||||
inv_1.tax_withholding_category = "TDS - 3"
|
inv_1.tax_withholding_category = tds_doc.name
|
||||||
|
inv_1.save()
|
||||||
inv_1.submit()
|
inv_1.submit()
|
||||||
|
|
||||||
inv_2 = make_purchase_invoice(
|
inv_2 = make_purchase_invoice(rate=1000, posting_date=from_date, do_not_save=True, do_not_submit=True)
|
||||||
rate=1000, do_not_submit=True, posting_date=add_to_date(mid_year, days=1), do_not_save=True
|
|
||||||
)
|
|
||||||
inv_2.set_posting_time = 1
|
inv_2.set_posting_time = 1
|
||||||
|
inv_2.apply_tds = 1
|
||||||
inv_1.apply_tds = 1
|
inv_2.tax_withholding_category = tds_doc.name
|
||||||
inv_2.tax_withholding_category = "TDS - 3"
|
|
||||||
inv_2.save()
|
inv_2.save()
|
||||||
inv_2.submit()
|
inv_2.submit()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user