Merge pull request #46789 from aerele/order-tax-table

fix: map tax table while creating purchase order from sales order
This commit is contained in:
ruthra kumar
2025-04-15 11:41:15 +05:30
committed by GitHub
2 changed files with 34 additions and 0 deletions

View File

@@ -1460,6 +1460,8 @@ def make_purchase_order(source_name, selected_items=None, target_doc=None):
target.customer = target.customer_name = target.shipping_address = None
target.run_method("set_missing_values")
if not target.taxes:
target.append_taxes_from_item_tax_template()
target.run_method("calculate_taxes_and_totals")
def update_item(source, target, source_parent):

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")