Skip to content

Commit

Permalink
fix: incorrect gross profit on the quotation (backport #40438) (#40442)
Browse files Browse the repository at this point in the history
fix: incorrect gross profit on the quotation (#40438)

(cherry picked from commit f4a945a)

Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
  • Loading branch information
mergify[bot] and rohitwaghchaure committed Mar 13, 2024
1 parent bc53b67 commit ce2626e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions erpnext/controllers/accounts_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class InvalidQtyError(frappe.ValidationError):
"weight_per_unit",
"weight_uom",
"total_weight",
"valuation_rate",
)


Expand Down
33 changes: 33 additions & 0 deletions erpnext/selling/doctype/quotation/test_quotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,39 @@ def test_make_sales_order_terms_copied(self):

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

Expand Down

0 comments on commit ce2626e

Please sign in to comment.