From 8d76e4d4981a06a5b7bee73a3a07c137e4284224 Mon Sep 17 00:00:00 2001 From: shubham Date: Fri, 17 Jan 2025 18:07:11 +0530 Subject: [PATCH] test: add test case for so creating si via delivery trip with gst 94 --- .../doctype/sales_order/test_sales_order.py | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/erpnext/selling/doctype/sales_order/test_sales_order.py b/erpnext/selling/doctype/sales_order/test_sales_order.py index de410ff93cd2..b883eeb0a898 100644 --- a/erpnext/selling/doctype/sales_order/test_sales_order.py +++ b/erpnext/selling/doctype/sales_order/test_sales_order.py @@ -4933,6 +4933,43 @@ def test_sales_order_delivery_trip_creating_si_with_returns_TC_S_093(self): self.assertEqual(frappe.db.get_value('GL Entry', {'voucher_no': si.name, 'account': 'Sales - _TC'}, 'credit'), 5000) self.assertEqual(frappe.db.get_value('GL Entry', {'voucher_no': si.name, 'account': 'Debtors - _TC'}, 'debit'), 5000) + def test_sales_order_delivery_trip_creating_si_with_gst_TC_S_094(self): + so = self.create_and_submit_sales_order_with_gst("_Test Item", qty=1, rate=5000) + + dn = make_delivery_note(so.name) + dn.submit() + + self.assertEqual(dn.status, "To Bill", "Delivery Note not created") + qty_change = frappe.db.get_value('Stock Ledger Entry', {'voucher_no': dn.name, 'warehouse': '_Test Warehouse - _TC', 'item_code': '_Test Item'},'actual_qty') + self.assertEqual(qty_change, -1) + + driver, vehicle, add = get_transport_details(customer = "_Test Registered Customer") + + from erpnext.stock.doctype.delivery_note.delivery_note import make_delivery_trip + trip = make_delivery_trip(dn.name) + trip.driver = driver.name + trip.vehicle = vehicle.name + trip.departure_time = frappe.utils.now() + for i in trip.delivery_stops: + i.address = add.name + trip.save() + trip.submit() + + self.assertEqual(trip.status, "Scheduled") + + from erpnext.stock.doctype.delivery_note.delivery_note import (make_sales_invoice) + + si = make_sales_invoice(dn.name) + si.save() + si.submit() + si.reload() + self.assertEqual(si.status, 'Unpaid') + self.assertEqual(frappe.db.get_value('GL Entry', {'voucher_no': si.name, 'account': 'Sales - _TC'}, 'credit'), 5000) + self.assertEqual(frappe.db.get_value('GL Entry', {'voucher_no': si.name, 'account': 'Debtors - _TC'}, 'debit'), 5000) + + so.reload() + self.assertEqual(so.per_billed, 100) + 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()