mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-04 20:59:11 +00:00
fix(Quotation): calculate row values for alternative items (#43054)
This commit is contained in:
@@ -573,12 +573,50 @@ class TestQuotation(FrappeTestCase):
|
||||
"description": "VAT",
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"rate": 10,
|
||||
"included_in_print_rate": 1,
|
||||
},
|
||||
)
|
||||
quotation.submit()
|
||||
|
||||
self.assertEqual(quotation.net_total, 290)
|
||||
self.assertEqual(quotation.grand_total, 319)
|
||||
self.assertEqual(round(quotation.items[1].net_rate, 2), 136.36)
|
||||
self.assertEqual(round(quotation.items[1].amount, 2), 150)
|
||||
|
||||
self.assertEqual(round(quotation.items[2].net_rate, 2), 163.64)
|
||||
self.assertEqual(round(quotation.items[2].amount, 2), 180)
|
||||
|
||||
self.assertEqual(round(quotation.net_total, 2), 263.64)
|
||||
self.assertEqual(round(quotation.total_taxes_and_charges, 2), 26.36)
|
||||
self.assertEqual(quotation.grand_total, 290)
|
||||
|
||||
def test_amount_calculation_for_alternative_items(self):
|
||||
"""Make sure that the amount is calculated correctly for alternative items when the qty is changed."""
|
||||
from erpnext.stock.doctype.item.test_item import make_item
|
||||
|
||||
item_list = []
|
||||
stock_items = {
|
||||
"_Test Simple Item 1": 100,
|
||||
"_Test Alt 1": 120,
|
||||
}
|
||||
|
||||
for item, rate in stock_items.items():
|
||||
make_item(item, {"is_stock_item": 0})
|
||||
item_list.append(
|
||||
{
|
||||
"item_code": item,
|
||||
"qty": 1,
|
||||
"rate": rate,
|
||||
"is_alternative": "Alt" in item,
|
||||
}
|
||||
)
|
||||
|
||||
quotation = make_quotation(item_list=item_list, do_not_submit=1)
|
||||
|
||||
self.assertEqual(quotation.items[1].amount, 120)
|
||||
|
||||
quotation.items[1].qty = 2
|
||||
quotation.save()
|
||||
|
||||
self.assertEqual(quotation.items[1].amount, 240)
|
||||
|
||||
def test_alternative_items_sales_order_mapping_with_stock_items(self):
|
||||
from erpnext.selling.doctype.quotation.quotation import make_sales_order
|
||||
|
||||
Reference in New Issue
Block a user