Skip to content

Commit

Permalink
fix: incorrect rate and amount in MR Item (#33547)
Browse files Browse the repository at this point in the history
* fix: incorrect `rate` and `amount` in MR Item
  • Loading branch information
s-aga-r authored Jan 22, 2023
1 parent 72be489 commit 7a8e89e
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion erpnext/selling/doctype/sales_order/sales_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from erpnext.selling.doctype.customer.customer import check_credit_limit
from erpnext.setup.doctype.item_group.item_group import get_item_group_defaults
from erpnext.stock.doctype.item.item import get_item_defaults
from erpnext.stock.get_item_details import get_default_bom
from erpnext.stock.get_item_details import get_default_bom, get_price_list_rate
from erpnext.stock.stock_balance import get_reserved_qty, update_bin_qty

form_grid_templates = {"items": "templates/form_grid/item_grid.html"}
Expand Down Expand Up @@ -590,6 +590,23 @@ def update_item(source, target, source_parent):
target.qty = qty - requested_item_qty.get(source.name, 0)
target.stock_qty = flt(target.qty) * flt(target.conversion_factor)

args = target.as_dict().copy()
args.update(
{
"company": source_parent.get("company"),
"price_list": frappe.db.get_single_value("Buying Settings", "buying_price_list"),
"currency": source_parent.get("currency"),
"conversion_rate": source_parent.get("conversion_rate"),
}
)

target.rate = flt(
get_price_list_rate(args=args, item_doc=frappe.get_cached_doc("Item", target.item_code)).get(
"price_list_rate"
)
)
target.amount = target.qty * target.rate

doc = get_mapped_doc(
"Sales Order",
source_name,
Expand Down

0 comments on commit 7a8e89e

Please sign in to comment.