fix: incorrect gross profit on the quotation (#40438)
(cherry picked from commit f4a945aee4)
Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
@@ -88,6 +88,7 @@ force_item_fields = (
|
||||
"weight_per_unit",
|
||||
"weight_uom",
|
||||
"total_weight",
|
||||
"valuation_rate",
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -30,6 +30,39 @@ class TestQuotation(FrappeTestCase):
|
||||
|
||||
self.assertTrue(sales_order.get("payment_schedule"))
|
||||
|
||||
def test_gross_profit(self):
|
||||
from erpnext.stock.doctype.item.test_item import make_item
|
||||
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
||||
from erpnext.stock.get_item_details import insert_item_price
|
||||
|
||||
item_doc = make_item("_Test Item for Gross Profit", {"is_stock_item": 1})
|
||||
item_code = item_doc.name
|
||||
make_stock_entry(item_code=item_code, qty=10, rate=100, target="_Test Warehouse - _TC")
|
||||
|
||||
selling_price_list = frappe.get_all("Price List", filters={"selling": 1}, limit=1)[0].name
|
||||
frappe.db.set_single_value("Stock Settings", "auto_insert_price_list_rate_if_missing", 1)
|
||||
insert_item_price(
|
||||
frappe._dict(
|
||||
{
|
||||
"item_code": item_code,
|
||||
"price_list": selling_price_list,
|
||||
"price_list_rate": 300,
|
||||
"rate": 300,
|
||||
"conversion_factor": 1,
|
||||
"discount_amount": 0.0,
|
||||
"currency": frappe.db.get_value("Price List", selling_price_list, "currency"),
|
||||
"uom": item_doc.stock_uom,
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
quotation = make_quotation(
|
||||
item_code=item_code, qty=1, rate=300, selling_price_list=selling_price_list
|
||||
)
|
||||
self.assertEqual(quotation.items[0].valuation_rate, 100)
|
||||
self.assertEqual(quotation.items[0].gross_profit, 200)
|
||||
frappe.db.set_single_value("Stock Settings", "auto_insert_price_list_rate_if_missing", 0)
|
||||
|
||||
def test_maintain_rate_in_sales_cycle_is_enforced(self):
|
||||
from erpnext.selling.doctype.quotation.quotation import make_sales_order
|
||||
|
||||
|
||||
Reference in New Issue
Block a user