Skip to content

Commit

Permalink
test: add test case so for stock unreserve
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham-DT committed Jan 16, 2025
1 parent 31ffb83 commit 67e4807
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion erpnext/selling/doctype/sales_order/test_sales_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -4486,7 +4486,7 @@ def test_sales_order_creating_invoice_with_installation_note_and_gst_TC_S_062(se
self.assertEqual(frappe.db.get_value('GL Entry', {'voucher_no': si.name, 'account': 'Output Tax SGST - _TIRC'}, 'credit'), 9)
self.assertEqual(frappe.db.get_value('GL Entry', {'voucher_no': si.name, 'account': 'Output Tax CGST - _TIRC'}, 'credit'), 9)

def test_sales_order_for_stock_reservation_TC_S_063(self, reuse=None):
def test_sales_order_for_stock_reservation_TC_S_063(self, reuse=None, get_so_with_stock_reserved=None):
make_stock_entry(item_code="_Test Item", qty=10, rate=5000, target="_Test Warehouse - _TC")

stock_setting = frappe.get_doc('Stock Settings')
Expand All @@ -4509,6 +4509,9 @@ def test_sales_order_for_stock_reservation_TC_S_063(self, reuse=None):

self.assertEqual(frappe.db.get_value("Stock Reservation Entry", {"voucher_no": so.name}, "status"), "Reserved")

if get_so_with_stock_reserved:
return so

dn = make_delivery_note(so.name)
dn.save()
dn.submit()
Expand Down Expand Up @@ -4756,6 +4759,15 @@ def test_sales_order_for_auto_stock_reservation_TC_S_070(self, reuse=None):
self.assertEqual(frappe.db.get_value('GL Entry', {'voucher_no': pi.name, 'account': 'Creditors - _TC'}, 'credit'), 5000)
self.assertEqual(frappe.db.get_value('GL Entry', {'voucher_no': pi.name, 'account': 'Cost of Goods Sold - _TC'}, 'debit'), 5000)

def test_sales_order_for_stock_unreserve_TC_S_071(self):
so = self.test_sales_order_for_stock_reservation_TC_S_063(get_so_with_stock_reserved=1)

from erpnext.stock.doctype.stock_reservation_entry.stock_reservation_entry import cancel_stock_reservation_entries

cancel_stock_reservation_entries(voucher_type="Sales Order", voucher_no=so.name, sre_list=None, notify=True)

self.assertEqual(frappe.db.get_value("Stock Reservation Entry", {"voucher_no": so.name}, "status"), "Cancelled")

def create_and_submit_sales_order(self, qty=None, rate=None):
sales_order = make_sales_order(cost_center='Main - _TC', selling_price_list='Standard Selling', do_not_save=True)
sales_order.delivery_date = nowdate()
Expand Down

0 comments on commit 67e4807

Please sign in to comment.