test: add pending quantity check for invoice creation

(cherry picked from commit e5d4b4f0f0)

# Conflicts:
#	erpnext/selling/doctype/sales_order/test_sales_order.py
This commit is contained in:
ravibharathi656
2025-08-25 21:04:51 +05:30
committed by Mergify
parent 54030eb721
commit b403b6c7b4

View File

@@ -2396,6 +2396,66 @@ class TestSalesOrder(AccountsTestMixin, FrappeTestCase):
self.assertFalse(so.per_billed)
self.assertEqual(so.status, "To Deliver and Bill")
<<<<<<< HEAD
=======
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 test_pending_quantity_after_update_item_during_invoice_creation(self):
so = make_sales_order(qty=30, rate=100)
si1 = make_sales_invoice(so.name)
si1.update_stock = 1
si1.get("items")[0].qty = 10
si1.insert()
si1.submit()
first_item_of_so = so.get("items")[0]
trans_item = json.dumps(
[
{
"item_code": first_item_of_so.item_code,
"rate": 1000,
"qty": first_item_of_so.qty,
"docname": first_item_of_so.name,
},
]
)
update_child_qty_rate("Sales Order", trans_item, so.name)
si2 = make_sales_invoice(so.name)
self.assertEqual(si2.items[0].qty, 20)
>>>>>>> e5d4b4f0f0 (test: add pending quantity check for invoice creation)
def automatically_fetch_payment_terms(enable=1):
accounts_settings = frappe.get_doc("Accounts Settings")