test: add unit test to validate tax values in Purchase Order from Sales Order

This commit is contained in:
Sugesh393
2025-03-29 15:35:01 +05:30
parent 1e18569be7
commit a393195866

View File

@@ -2360,6 +2360,38 @@ class TestSalesOrder(AccountsTestMixin, IntegrationTestCase):
sre_doc.reload()
self.assertTrue(sre_doc.status == "Delivered")
def test_item_tax_transfer_from_sales_to_purchase(self):
from erpnext.selling.doctype.sales_order.sales_order import make_purchase_order
item_tax = frappe.new_doc("Item Tax Template")
item_tax.title = "Test Item Tax Template"
item_tax.company = "_Test Company"
item_tax.append("taxes", {"tax_type": "_Test Account Service Tax - _TC", "tax_rate": 2})
item_tax.save()
item_group = frappe.get_doc("Item Group", "_Test Item Group")
item_group.append("taxes", {"item_tax_template": "Test Item Tax Template - _TC"})
item_group.save()
so = make_sales_order(item_code="_Test Item", qty=1, do_not_submit=1)
so.append(
"taxes",
{
"account_head": "_Test Account Service Tax - _TC",
"charge_type": "On Net Total",
"description": "TDS",
"doctype": "Sales Taxes and Charges",
"rate": 2,
},
)
so.submit()
po = make_purchase_order(so.name, selected_items=so.items)
po.supplier = "_Test Supplier"
po.items[0].rate = 100
po.submit()
self.assertEqual(po.taxes[0].tax_amount, 2)
def automatically_fetch_payment_terms(enable=1):
accounts_settings = frappe.get_doc("Accounts Settings")