fix: Test Product Bundle price calculation
This commit is contained in:
parent
0c3d3bb357
commit
0e457265b7
@ -257,8 +257,56 @@ class TestQuotation(unittest.TestCase):
|
||||
|
||||
self.assertEqual(quotation_packed_items, so_packed_items)
|
||||
|
||||
def test_product_bundle_price_calculation_when_calculate_bundle_price_is_unchecked(self):
|
||||
from erpnext.stock.doctype.item.test_item import make_item
|
||||
from erpnext.selling.doctype.product_bundle.test_product_bundle import make_product_bundle
|
||||
|
||||
make_item("_Test Product Bundle", {"is_stock_item": 0})
|
||||
bundle_item1 = make_item("_Test Bundle Item 1", {"is_stock_item": 1})
|
||||
bundle_item2 = make_item("_Test Bundle Item 2", {"is_stock_item": 1})
|
||||
|
||||
make_product_bundle("_Test Product Bundle",
|
||||
["_Test Bundle Item 1", "_Test Bundle Item 2"])
|
||||
|
||||
bundle_item1.valuation_rate = 100
|
||||
bundle_item1.save()
|
||||
|
||||
bundle_item2.valuation_rate = 200
|
||||
bundle_item2.save()
|
||||
|
||||
quotation = make_quotation(item_code="_Test Product Bundle", qty=2, rate=100)
|
||||
self.assertEqual(quotation.items[0].amount, 200)
|
||||
|
||||
def test_product_bundle_price_calculation_when_calculate_bundle_price_is_checked(self):
|
||||
from erpnext.stock.doctype.item.test_item import make_item
|
||||
from erpnext.selling.doctype.product_bundle.test_product_bundle import make_product_bundle
|
||||
|
||||
make_item("_Test Product Bundle", {"is_stock_item": 0})
|
||||
make_item("_Test Bundle Item 1", {"is_stock_item": 1})
|
||||
make_item("_Test Bundle Item 2", {"is_stock_item": 1})
|
||||
|
||||
make_product_bundle("_Test Product Bundle",
|
||||
["_Test Bundle Item 1", "_Test Bundle Item 2"])
|
||||
|
||||
enable_calculate_bundle_price()
|
||||
|
||||
quotation = make_quotation(item_code="_Test Product Bundle", qty=2, rate=100, do_not_submit=1)
|
||||
quotation.packed_items[0].rate = 100
|
||||
quotation.packed_items[1].rate = 200
|
||||
quotation.save()
|
||||
|
||||
self.assertEqual(quotation.items[0].amount, 600)
|
||||
self.assertEqual(quotation.items[0].rate, 300)
|
||||
|
||||
enable_calculate_bundle_price(enable=0)
|
||||
|
||||
test_records = frappe.get_test_records('Quotation')
|
||||
|
||||
def enable_calculate_bundle_price(enable=1):
|
||||
selling_settings = frappe.get_doc("Selling Settings")
|
||||
selling_settings.editable_bundle_item_rates = enable
|
||||
selling_settings.save()
|
||||
|
||||
def get_quotation_dict(party_name=None, item_code=None):
|
||||
if not party_name:
|
||||
party_name = '_Test Customer'
|
||||
|
Loading…
x
Reference in New Issue
Block a user