fix: update total in words after updating items (#24602)

* fix: Update total in words after Updating items

Update total in words after Updating items in sales/purchase orders.
Port of #24592

Closes ISS-20-21-09425

* test: Add test for total & words after update item

Add test for total & words after updating items in sales order.
This commit is contained in:
Ankush Menat 2021-02-11 11:04:39 +05:30 committed by Nabin Hait
parent 83792ec009
commit 4b2cbdc2dd
2 changed files with 10 additions and 0 deletions

View File

@ -1503,6 +1503,7 @@ def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name, chil
parent.flags.ignore_validate_update_after_submit = True
parent.set_qty_as_per_stock_uom()
parent.calculate_taxes_and_totals()
parent.set_total_in_words()
if parent_doctype == "Sales Order":
make_packing_list(parent)
parent.set_gross_profit()

View File

@ -325,6 +325,9 @@ class TestSalesOrder(unittest.TestCase):
create_dn_against_so(so.name, 4)
make_sales_invoice(so.name)
prev_total = so.get("base_total")
prev_total_in_words = so.get("base_in_words")
first_item_of_so = so.get("items")[0]
trans_item = json.dumps([
{'item_code' : first_item_of_so.item_code, 'rate' : first_item_of_so.rate, \
@ -340,6 +343,12 @@ class TestSalesOrder(unittest.TestCase):
self.assertEqual(so.get("items")[-1].amount, 1400)
self.assertEqual(so.status, 'To Deliver and Bill')
updated_total = so.get("base_total")
updated_total_in_words = so.get("base_in_words")
self.assertEqual(updated_total, prev_total+1400)
self.assertNotEqual(updated_total_in_words, prev_total_in_words)
def test_update_child_removing_item(self):
so = make_sales_order(**{
"item_list": [{