From 2d1db2e4038d25e71c44e26dbbd427b30ae7fc2d Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Wed, 31 Dec 2025 16:40:40 +0530 Subject: [PATCH] refactor(test): make purchase receipt deterministic --- .../purchase_receipt/test_purchase_receipt.py | 14 ++- .../purchase_receipt/test_records.json | 87 +++++++++++++++++++ 2 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 erpnext/stock/doctype/purchase_receipt/test_records.json diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py index 346e6bb8d54..ba4d9419128 100644 --- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py @@ -29,6 +29,11 @@ from erpnext.tests.utils import ERPNextTestSuite class TestPurchaseReceipt(ERPNextTestSuite): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.load_test_records("Purchase Receipt") + def setUp(self): frappe.db.set_single_value("Buying Settings", "allow_multiple_items", 1) @@ -741,7 +746,12 @@ class TestPurchaseReceipt(ERPNextTestSuite): serial_no = ["12903812901"] if not frappe.db.exists("Serial No", serial_no[0]): frappe.get_doc( - {"doctype": "Serial No", "item_code": item_code, "serial_no": serial_no[0]} + { + "doctype": "Serial No", + "item_code": item_code, + "serial_no": serial_no[0], + "company": self.companies[0].name, + } ).insert() pr_doc = make_purchase_receipt(item_code=item_code, qty=1, serial_no=serial_no) @@ -2699,6 +2709,7 @@ class TestPurchaseReceipt(ERPNextTestSuite): "doctype": "Serial No", "item_code": serial_item, "serial_no": serial_no, + "company": self.companies[0].name, } ).insert() @@ -3990,6 +4001,7 @@ class TestPurchaseReceipt(ERPNextTestSuite): "doctype": "Serial No", "item_code": serial_item, "serial_no": serial_no, + "company": self.companies[0].name, } ).insert() diff --git a/erpnext/stock/doctype/purchase_receipt/test_records.json b/erpnext/stock/doctype/purchase_receipt/test_records.json new file mode 100644 index 00000000000..86f8683ce25 --- /dev/null +++ b/erpnext/stock/doctype/purchase_receipt/test_records.json @@ -0,0 +1,87 @@ +[ + { + "buying_price_list": "_Test Price List", + "company": "_Test Company", + "conversion_rate": 1.0, + "currency": "INR", + "doctype": "Purchase Receipt", + "base_grand_total": 720.0, + "naming_series": "_T-Purchase Receipt-", + "base_net_total": 500.0, + "taxes": [ + { + "account_head": "_Test Account Shipping Charges - _TC", + "add_deduct_tax": "Add", + "category": "Valuation and Total", + "charge_type": "Actual", + "description": "Shipping Charges", + "doctype": "Purchase Taxes and Charges", + "parentfield": "taxes", + "rate": 100.0, + "tax_amount": 100.0, + "cost_center": "Main - _TC" + }, + { + "account_head": "_Test Account VAT - _TC", + "add_deduct_tax": "Add", + "category": "Total", + "charge_type": "Actual", + "description": "VAT", + "doctype": "Purchase Taxes and Charges", + "parentfield": "taxes", + "rate": 120.0, + "tax_amount": 120.0, + "cost_center": "Main - _TC" + }, + { + "account_head": "_Test Account Customs Duty - _TC", + "add_deduct_tax": "Add", + "category": "Valuation", + "charge_type": "Actual", + "description": "Customs Duty", + "doctype": "Purchase Taxes and Charges", + "parentfield": "taxes", + "rate": 150.0, + "tax_amount": 150.0, + "cost_center": "Main - _TC" + } + ], + "items": [ + { + "base_amount": 250.0, + "conversion_factor": 1.0, + "description": "_Test Item", + "doctype": "Purchase Receipt Item", + "item_code": "_Test Item", + "item_name": "_Test Item", + "parentfield": "items", + "qty": 5.0, + "rate": 50.0, + "received_qty": 5.0, + "rejected_qty": 0.0, + "stock_uom": "_Test UOM", + "uom": "_Test UOM", + "warehouse": "_Test Warehouse - _TC", + "cost_center": "Main - _TC" + }, + { + "base_amount": 250.0, + "conversion_factor": 1.0, + "description": "_Test Item Home Desktop 100", + "doctype": "Purchase Receipt Item", + "item_code": "_Test Item Home Desktop 100", + "item_name": "_Test Item Home Desktop 100", + "parentfield": "items", + "qty": 5.0, + "rate": 50.0, + "received_qty": 5.0, + "rejected_qty": 0.0, + "stock_uom": "_Test UOM", + "uom": "_Test UOM", + "warehouse": "_Test Warehouse 1 - _TC", + "cost_center": "Main - _TC" + } + ], + "supplier": "_Test Supplier" + } +]