Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: incorrect gross profit on the quotation #40438

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -42,6 +42,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
Loading